ホームページ >バックエンド開発 >PHPチュートリアル >PHP の 2 番目のドロップダウン メニューのリンクに関連する問題
PHP のセカンダリ ドロップダウン メニューのリンクの問題
<br /> <br /> <br /> <script language="javascript"><br /> var subcat2 = new Array();<br /> <?php<br /> require('config.php');<br /> $i=0;<br /> $sql="select * from p_cclass ";//查询所有小类<br /> $result=MySQL_query($sql);<br /> while($rs=mysql_fetch_array($result))<br /> {<br /> echo "subcat2[".$i++."] = new Array('".$rs["cc_id"]."','".$rs["cid_ccid"]."','".$rs["classname"]."');\n";<br /> }<br /> ?><br /> function changeselect1(locationid)<br /> {<br /> document.myform.cc_id.length = 0;<br /> document.myform.cc_id.options[0] = new Option('暂无二级分类','');<br /> //alert(subcat2[1].toString());<br /> //alert(locationid.length.toString());<br /> for (i=0; i<subcat2.length; i++)<br /> {<br /> if (subcat2[i][1] == locationid)<br /> {<br /> document.myform.cc_id.options[document.myform.cc_id.length] = new Option(subcat2[i][2], subcat2[i][0]);}<br /> document.myform.cc_id.options[0] = new Option('==请选择二级分类==','');<br /> <br /> <br /> }<br /> }<br /> </script><br /> <br /> <br /> <form action="pro_edit.php" method="post" name="myform" id="myform" ><br /> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F1F5F8"><br /> <tr><br /> <td width="697" height="51"><table width="100%" height="175" border="0" cellpadding="0" cellspacing="0"><br /> <tr><br /> <td height="31" colspan="2" align="center" bgcolor="#D6E7F7">修改产品</td><br /> </tr><br /> <tr><br /> <td width="65" height="26"> 产品类型:</td><br /> <td width="632" height="26"><select name="c_id" id="c_id" onChange="changeselect1(this.value)" style="width:100;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff"><br /> <?php<br /> require("config.php"); //包含文件<br /> <br /> $p_id=$_GET["p_id"];<br /> $sqlp = "select * from product where p_id='$p_id'"; <br /> $rsp=mysql_query($sqlp); <br /> $rscountp=mysql_fetch_array($rsp);<br /> <br /> $c_id=$rscountp["p_cid"];<br /> $sql="select * from p_class where c_id='$c_id'";//查询表<br /> $rs=mysql_query($sql);<br /> $rscount=mysql_fetch_array($rs)<br /> <br /> ?><br /> <option value="<?=$rscount["c_id"]?>"><?=$rscount["classname"]?></option><br /> <?php<br /> $sqln="select * from p_class where c_id!='$c_id'";//查询表<br /> $rsn=mysql_query($sqln);<br /> while($rscountn=mysql_fetch_array($rsn)){ <br /> ?><br /> <option value="<?=$rscountn["c_id"]?>"><?=$rscountn["classname"]?></option><br /> <?php<br /> }<br /> ?><br /> </select><br /> <br /> <br /> </select><br /> <select name="cc_id" id="cc_id" style="width:100;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff"><br /> <br /> <?php<br /> <br /> $p_id=$_GET["p_id"];<br /> $sqla = "select * from product where p_id='$p_id'"; <br /> $rsa=mysql_query($sqla); <br /> $rscounta=mysql_fetch_array($rsa);<br /> <br /> <br /> $c_id=$rscounta["p_cid"];<br /> <br /> <br /> $sqlb = "select * from p_class where c_id='$c_id'"; <br /> $rsb=mysql_query($sqlb); <br /> $rscountb=mysql_fetch_array($rsb);<br /> <br /> <br /> $cid_ccid=$rscountb["c_id"];<br /> ?><br /> <br /> <br /> <?php<br /> $sqlc = "select * from p_cclass where cid_ccid='$cid_ccid'"; //条件小分类<br /> $rsc=mysql_query($sqlc); <br /> $rscountc=mysql_fetch_array($rsc);<br /> ?><br /> <option value="<?=$rscountc["cc_id"]?>"><?=$rscountc["classname"]?></option><br /> <br /> <br /> <?php<br /> $sqla="select * from p_cclass where cid_ccid='$cid_ccid'";//查询表<br /> $rsc=mysql_query($sqlc);<br /> while($rscountc=mysql_fetch_array($rsc)){ <br /> ?><br /> <option value="<?=$rscountc["cc_id"]?>"><?=$rscountc["classname"]?></option><br /> <br /> <?php<br /> }<br /> ?><br /> </select><br /> <br /> </label></td><br /> </tr><br /> <br /> <tr><br /> <td height="59" align="center"><input type="submit" name="Submit" value="确定提交" onclick="return Check();" /><br /> <br /> <input name="p_id" type="hidden" id="p_id" value="<?=$rscountp["p_id"]?>" /><br /> <br /> <input type="reset" name="Submit2" value="重置" /><br /> <textarea name="p_content" id="p_content" style="display:none;"><br /> <?=$rscountp["p_content"]?><br /> <br /> </textarea></td><br /> </tr><br /> </table><br /> </form><br /> <br />