0

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

1 回答 1

1

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

于 2013-01-01T18:37:26.623 回答