繁体   English   中英

无法从javascript函数调用PHP文件

[英]PHP file not being called from javascript function

我正在尝试从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>

您不能直接从javascript调用php函数。 利用一些ajax调用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM