php二级联动菜单改动版
/**************************************************************************************************************************php二级联动菜单改动版***************************************************************************by garcon1986***************************************************************************************************************************************/2chain.php:<mce:script language = "JavaScript"><!--var onecount; onecount=0; subcat = new Array(); <?php mysql_connect("localhost","charles","charles"); mysql_select_db( "_crm" ); $sql = "select * from site"; $result = mysql_query( $sql ); $count = 0; while($res = mysql_fetch_row($result)){ ?> subcat[<?php echo $count ?>] = new Array("<?php echo $res?>","<?php echo $res?>","<?php echo $res?>"); <?php $count++; } echo "onecount=$count;"; ?> //联动函数 function changelocation(locationid) { document.myform.ctype.length = 0;var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat == locationid) {//var newOption1=new Option(subcat, subcat); //document.all.ctype.add(newOption1); document.myform.ctype.options = new Option(subcat, subcat); } }}// --></mce:script><form method="post" name="myform" action="ru_query.php"> <select name="type" onChange="changelocation(document.myform.type.options.value)" size="1"> <option selected value="">main</option> <?php $sql = "select * from entreprise"; $result = mysql_query( $sql ); while($res = mysql_fetch_row($result)){ ?> <option value="<?php echo $res; ?>"><?php echo $res; ?></option> <?php } ?> </select><select name="ctype"> <option selected value="">sub</option> </select> <input type="submit" name="Submit" value="search"> </form>数据库表格结构:entreprise: id, namesite: id, eid, namesite中的eid即为entreprise的id。
页:
[1]