PHP文件没有从javascript函数调用

时间:2013-01-01 18:26:59

标签: php javascript forms cookies

我试图从javascript函数调用一个表单和php文件,但它不起作用。它可能与cookie有关,它不会调用“frmSubdeptChainDailyHL”表单而且它不会调用“subdeptclass_reportHL.php”文件,这里是代码:

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>

1 个答案:

答案 0 :(得分:1)

你无法从javascript直接调用php函数。利用一些ajax调用