require_once('db.inc.php');//数据库连接 $db=new hq_online; $db1=new hq_online; $db->query("select * from news_bclass order by id desc"); $fmenu=""; $fvalue=""; while($db->next_record()){ $fmenu.="/"".$db->record["bname"]."/","; $fvalue.="/"".$db->record["id"]."/",";
//得到*****************************var smenu $db->query("select * from news_bclass order by id desc"); while($db->next_record()){ $parentid=$db->record["id"]; $db1->query("select * from news_sclass where parentid='$parentid' order by parentid desc"); while($db1->next_record()){ $num=$db1->num_rows(); $i++; $smenu.="/"".$db1->record["sname"]."/","; if($i==$num){ $smenu="[".$smenu."],["; $i=0; } } } $smenu.="]"; $smenu=str_replace("/",]","/"]",$smenu); $smenu=str_replace(",[]","]",$smenu); if((substr($smenu,0,2))=="[/""){ $smenu="[".$smenu; }else{ $smenu=preg_replace("//[{3,}/is","[[//1",$smenu);//匹配 }
//得到*****************************var svalue $db->query("select * from news_bclass order by id desc"); while($db->next_record()){ $parentid=$db->record["id"]; $db1->query("select * from news_sclass where parentid='$parentid' order by parentid desc"); while($db1->next_record()){ $nums=$db1->num_rows(); $j++; $svalue.="/"".$db1->record["id"]."/","; if($j==$nums){ $svalue="[".$svalue."],["; $j=0; } } } $svalue.="]"; $svalue=str_replace("/",]","/"]",$svalue); $svalue=str_replace(",[]","]",$svalue); if((substr($svalue,0,2))=="[/""){ $svalue="[".$svalue; }else{ $svalue=preg_replace("//[{3,}/is","[[//1",$svalue);//匹配 }
?> <div id="tar"></div> <script language="javascript" defer> var fmenu = <?php echo $fmenu; ?>; var fvalue = <?php echo $fvalue; ?>; var smenu = <?php echo $smenu; ?>; var svalue = <?php echo $svalue; ?>;
var owhere = document.all.tar; var ofmenu = document.createelement("<select name='bigclass'>"); var osmenu = document.createelement("<select name='smallclass'>"); with(owhere)appendchild(ofmenu),appendchild(osmenu);