0

I am trying to call a form and php filefrom a javascript function but it does not work. It might have to do with the cookies, it does not call the "frmSubdeptChainDailyHL" form and it does not call the "subdeptclass_reportHL.php" file, here is the code:

function submitClassChainDaily()
{
    var store = readCookie('storeAccess');
    var clss = readCookie('classAccess');
    var subdept = readCookie('subDeptAccess');
  var period = readCookie('period');
  if (period == null || period == '') {
    period = 'CUR';
  }
  document.frmClassChainDaily.period.value = period;

    var storePref = readCookie('storePref');


  if (storePref == null || storePref == '') {
    if (store == null || store == '') {
        storePref = 'ALL';

    } else {
        storePref = store;



    }
  }
    if ((storePref.length) > 3 && storePref != 'ALL100') {
        document.setStore.submit();
    } else {
    document.frmClassChainDaily.store.value = storePref;
    if (clss == null || clss == '') {
        clss = 'ALL';
    }
      document.frmClassChainDaily.clss.value = clss;
    if (subdept == null || subdept == '') {
        subdept = 'ALL';
    }
      document.frmClassChainDaily.subdept.value = subdept;

    ";

      if ($_REQUEST['storePref']=='099')
    {    
    echo "document.frmSubdeptChainDailyHL.submit();";
} else {
    echo "document.frmSubdeptChainDaily.submit();";
}   
 echo "


  }
}



Here is the form code:

if ($_REQUEST['storeCode'] == '099') {
        echo"
<li>
    <!--   SubDept Daily Sales - Chain -->
    <form name=\"frmSubdeptChainDailyHL\" action=\"subdeptclass_reportHL.php\">
        <input type=hidden value=\"\" name=\"store\">
        <input type=hidden value=\"\" name=\"subdept\">
        <input type=hidden value=\"\" name=\"clss\">
        <input type=hidden value=\"\" name=\"period\">
    </form>
      <a style=\"display: block; text-decoration: none; color: #000\" href=\"javascript: submitSubDeptChainDaily();\">
        <h3 class=\"longfield\">
            <img src=\"content/images/icons/US_dollar_icon.png\" alt=\"icon\" class=\"icon\"/>
            <span>Sales</span>
        </h3>
      </a>
      </li>
3
  • One is 'storePref' and the other is 'storeCode'. Is that correct? Commented Jan 1, 2013 at 18:35
  • oh yes, sorry they are both storePref, I forgot to change the 2nd one. Commented Jan 1, 2013 at 18:45
  • setstore also has to do with the cookie and permissions I believe, sorry even I am just modifying this code: <!-- Need to set store. --> <form name=\"setStore\" action=\"setStore.html\"> </form> <!-- User does not have access to the report requested. --> <form name=\"notPermit\" action=\"notPermitted.html\"> </form> Commented Jan 1, 2013 at 18:47

1 Answer 1

1

You cant directly call to a php function from javascript. Make use of some ajax calls

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.