Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
动态列表/菜单传递变量php_Php_Javascript_Mysql - Fatal编程技术网

动态列表/菜单传递变量php

动态列表/菜单传递变量php,php,javascript,mysql,Php,Javascript,Mysql,我在php代码中有这个2列表菜单。我的问题是如何在listmenu中获得所选值并将其传递给新查询,以便在第2个listmenu中。。根据第一个列表菜单中的值选择要执行的值。。。下面是我的代码 我有3个文件,分别名为addpage.php、addpage.html和changing process grades.php addpage.php和addpage.html <?php $level =$template->form_listmenu($lnames,$lvalues,$

我在php代码中有这个2列表菜单。我的问题是如何在listmenu中获得所选值并将其传递给新查询,以便在第2个listmenu中。。根据第一个列表菜单中的值选择要执行的值。。。下面是我的代码

我有3个文件,分别名为addpage.php、addpage.html和changing process grades.php

addpage.php和addpage.html

<?php

 $level =$template->form_listmenu($lnames,$lvalues,$level,"level",NULL,'width:300px;','onChange="dochange(\'gradedrop\', this.value, \'\',\'\');"',True);

$gnames=array("-- Please Select --");
$gvalues=array("");

$subnames=array("-- Please Select --");
$subvalues=array("");

$booknames=array("Select Books");
$bookvalues=array("");

$grade = $template->form_listmenu($gnames,$gvalues,$grade,"grade",NULL,'width:300px;','',FALSE);
$subject = $template->form_listmenu($subnames,$subvalues,$subject,"subject",NULL,'width:300px;','',FALSE);
$books = $template->form_listmenu($booknames,$bookvalues,$books,"books",NULL,'width:300px;','',FALSE);
 ?>
addpage.html文件

<html>

 <script language=Javascript>
  function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
  };

  function dochange(src, val, currval , currval1) {
   var req = Inint_AJAX();
   req.onreadystatechange = function () { 
      if (req.readyState==4) {
           if (req.status==200) {
                document.getElementById(src).innerHTML=req.responseText; //retuen value
           } 
       }
  };
   req.open("GET", "{domain}admin/modules/onlinetools/grades.php?data="+src+"&val="+val+"&currval="+currval+"&currval1="+currval1); //make connection
 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
 req.send(null); //send value
}

Grades.php

<?php
    ///this is the grades.php

    $val = $_GET["val"];
$grade = $_GET["currval"];
$subject = $_GET["currval1"];

 // Generate book subject table
$sql="SELECT * FROM booksubject WHERE status = '1' AND lid = '".$val.
     "' AND subject <> '#N/A' ORDER BY subject ASC";
$query=mysql_query($sql);
$data_num=mysql_num_rows($query);
//$data=mysql_fetch_array($query);
$subnames="-- Please Select --<:>";
$subvalues="<:>";
for($i=1; $i<=$data_num; $i++){
    $data=mysql_fetch_array($query);
    $subnames.=$subcoma.$data["subject"];
    $subvalues.=$subcoma.$data["sid"];
    $subcoma="<:>"; 

}
//  Generate book  table
$bsql="SELECT * FROM books WHERE subject = '".
          $data["sid"]."' ORDER BY title ASC";
$bquery=mysql_query($bsql);
$bdata_num=mysql_num_rows($bquery);
for($b=1; $b<=$bdata_num; $b++){
    $bdata=mysql_fetch_array($bquery);
    $booknames.=$bookcoma.$bdata["title"].' - '.$bdata["book_code"];
    $bookvalues.=$bookcoma.$bdata["bid"];
    $bookcoma="<:>";        
}


$subnames=explode("<:>",$subnames);
$subvalues=explode("<:>",$subvalues);
$subject = $template->form_listmenu($subnames,$subvalues,$subject,
                                    "subject",NULL,'width:300px;','',False);
echo '<p>'.$subject.'</p>';

$booknames=explode("<:>",$booknames);
$bookvalues=explode("<:>",$bookvalues);
$books = $template->form_listmenu($booknames,$bookvalues,$books,
                                    "books",NULL,'width:300px;','',FALSE);
echo '<p>'.$books.'</p>';
?>

您正在寻找Javascript方法吗?它们是两个选项菜单吗?我看到了两个解决方案:一个好的Ajax解决方案和一个在页面重新加载时使用会话的糟糕解决方案。示例:如果可能的话,我需要一个javascript方法。@hornebzz-dude我已经在使用ajax了。。但我不知道的是如何在ajax中传回变量。。并使用它。。我将修改我的代码来详细说明这个过程。。。