main.php <br> <!--<br /> <br /> function getoption(select1,target)<br /> {<br /> If(select1.value!=0){<br /> //select1 is the select menu name of the source of submitted data<br /> var url = "getoption.php?pid="+select1.value;//Get the url of xml<br /> //alert(url);<br /> var ajax = InitAjax();<br /> var i = 0;<br /> ajax.open("GET", url, true);<br /> ajax.onreadystatechange = function() {<br /> //If the execution status is normal, then assign the returned content to the specified place<br /> If (ajax.readystate == 4 && ajax.status == 200) {<br /> var obj = ajax.responseXML;<br /> var properties = obj.getElementsByTagName("property");<br /> var name,value;<br /> target.options.length = 1;<br /> for (var i=0,x=1;i<properties.length;i++,x++) {<br /> name = properties[i].getElementsByTagName("name")[0].firstChild.nodeValue;<br /> Target.Options [x] = New Option (); <br /> Target.Options [x] .text = name; <br /> target.options[x].value = value;<br /> }<br /> }<br /> }<br /> ajax.send(null);<br /> }<br /> }<br /> <br /> <br /> <form method="post" name="form" action="index.php"><br> <select name="level1" onchange="getoption(document.form.level1,document.form.level2);"/><br> <option selected="ture" value="0">===Select===</option><br> <?<br /> if ($nrows>0){<br> for ($i=0;$i<$nrows;$i++){<br /> echo "<option value="{$results[ID][$i]}">{$results[NAME][$i]}</option>";<br> }<br> }<br> ?><br> </select><br> <select name="level2" onchange="getoption(document.form.level2,document.form.level3);"><br> <option selected="ture" value="0">===Select===</option><br> </select><br> <br> iniajax.js:<br> function InitAjax()<br> {<br> var ajax=false;<br> Try {<br> ajax = new ActiveXObject("Msxml2.XMLHTTP");<br> } catch (e) {<br> try {<br> ajax = new ActiveXObject("Microsoft.XMLHTTP");<br> } catch (E) {<br> ajax = false;<br> }<br> }<br> If (!ajax && typeof XMLHttpRequest!=undefined) {<br> ajax = new XMLHttpRequest();<br> }<br> Return ajax;<br> }<br> <br> getoption.php:<br> <?php<br /> if($pid=$_GET["pid"])<br /> {<br /> header("Content-type: text/xml;charset=GB2312");<br /> echo "<?xml version="1.0" encoding="GB2312"?>";<br> include("./oracle.inc");<br> $sql="select * from AJAXTEST where PARENTID = $pid";<br> //echo $sql;<br> $stmt=ociparse($handle,$sql);<br> ociexecute($stmt);<br> ocicommit($handle);<br> ocilogoff();<br> $nrows=ocifetchstatement($stmt,$results);<br> echo "<properties>";<br> //echo "<row>{$nrows}</row>";<br> for ($i=0;$i<$nrows;$i++){<br /> echo "<property>";<br> echo "<value>{$results[ID][$i]}</value>";<br> echo "<name>{$results[NAME][$i]}</name>";<br> echo "</property>";<br> }<br> echo "</properties>";<br> }<br> ?></p> <p align="left"></p> <div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/486525.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/486525.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">main.php script language=javascript src=initajax.js/script!--InitAjax()-- script !-- function getoption(select1,target) { if(select1.value!=0){ //select1是提交数据的来源的...</span> </div> <div class="art_confoot"></div>