Php - 使用oracle查询值填充选择

时间:2014-09-04 06:52:16

标签: javascript php html html5 oracle11g

我的HTML中有三个<select>标记。

<select id = "deptSelect" onchange = "select1Changed(this.value)">
<option value = "1">Dept1</option>
<option value = "2">Dept2</option>
<option value = "3">Dept3</option>
</select>

<select id = "processSelect" onchange = "Select2Changed(this.value)">
<option value = "">Please Select</option>
</select>

<select id = "categorySelect" onChange = "Select3Changed(this.value)">
<option value = "">Please Select</option>
</select>

我希望实现一个方案,以便在选择特定部门时,processSelect填写该部门的所有相关流程,从processSelect所有相关类别中选择特定流程流程填充在categorySelect

的Javascript

function categorySelect(value)
{

var arg= value;
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//alert ("Returned");
//Get value from php page that executes select statement into ProcessArray 
}
else 
alert("Nothing");   
}

xmlhttp.open("GET","fetch.php?q="+comboOption,true);
xmlhttp.send();

for(m = 0; m < ProcessArray.length; m++)
{
var option = document.createElement('option'); //On selection of this option, another query has to be executed and values has to be returned in categorySelect select
option.innerHTML = ProcessArray[m].name;
option.value = ProcessArray[m].code;
category.appendChild(option);
category.value = ProcessArray[0].code;     
}

PHP:

$q = intval($_GET['q']);
$i = 0;
$j;

$conn = OCILogon("abc","abc","abc_server");
$qry_process = "SELECT CATEGORYSHORTCODE, CATEGORYDESCRIPTION FROM tableAbcWHERE PROCESSid = ".$q;
$qry_category= OCIParse($conn,$qry_process);
OCIDefineByName($qry_category,"CATEGORYSHORTCODE",$CATEGORYSHORTCODE);
OCIDefineByName($qry_category,"CATEGORYDESCRIPTION",$CATEGORYDESCRIPTION);
OCIExecute($qry_category);

while(OCIFetch(qry_category))

{

$categoryArray = array(array($i,$CATEGORYSHORTCODE,$CATEGORYDESCRIPTION)); 

}

如何在我的Javascript中返回此$categoryArray和useit?

0 个答案:

没有答案