普通php二级联动菜单,级联菜单
数据库结构与《ajax php二级联动菜单》相同

代码
PHP Code
- <script language = "JavaScript">
- var onecount;
- onecount=0;
- subcat = new Array();
- <?
- //类别选择
- mysql_select_db($database_lr, $lr);
- $sql = "select * from smallclass";
- $result = mysql_query( $sql );
- $count = 0;
- while($res = mysql_fetch_row($result)){
- ?>
- subcat[<?=$count?>] = new Array("<?=$res[0]?>","<?=$res[1]?>","<?=$res[2]?>");
- <?
- $count++;
- }
- echo "onecount=$count;";
- ?>
- function changelocation(locationid)
- {
- document.myform.smallclassid.length = 0;
- var locationid=locationid;
- var i;
- for (i=0;i < onecount; i++)
- {
- if (subcat[i][2] == locationid)
- {
- //var newOption1=new Option(subcat[i][1], subcat[i][0]);
- //document.all.smallclassid.add(newOption1);
- document.myform.smallclassid.options[document.myform.smallclassid.length] = new Option(subcat[i][1], subcat[i][0]);
- }
- }
- }
- </script>
- <h1 class="logo"><a href="http://www.freejs.net" title="freejs首页"><img src="../../images/logo.png" height="47" width="500" alt="freejs首页" /></a></h1>
- <div id="main_demo">
- <div align="center"><h2><a href="http://www.freejs.net/article_biaodan_30.html">普通php二级联动菜单,级联菜单</a></h2></div>
- <form method="post" name="myform" action="" onSubmit="return CheckForm();" style="text-align:center">
- 选择类别:<select name="bigclassid" onChange="changelocation(document.myform.bigclassid.options[document.myform.bigclassid.selectedIndex].value)" size="1">
- <option selected value="">选择大类</option>
- <?
- $sql = "select * from bigclass order by sort";
- $result = mysql_query( $sql );
- while($res = mysql_fetch_row($result)){
- ?>
- <option value="<? echo $res[0]; ?>"><? echo $res[1]; ?></option>
- <? } ?>
- </select>
- <select name="smallclassid">
- <option selected value="">选择小类别</option>
- </select>
- </form>
原文地址:http://www.freejs.net/article_biaodan_30.html
最近更新
- 响应式全屏手风琴菜单,同时支持垂直方...
- 分组select选择器,支持多选和单...
- jQuery时间日期选择器代码日历插...
- Select 选择器 可以清空的单选...
- jQuery json 无刷新翻页 ...
- 纯css3带倒影效果的图片翻转特效
我爱薅羊毛
点击最多
广告赞助
相关文章
- 美化input radio select等输入框,...
- select 下拉框多选,用select代替che...
- jQuery下拉多选插件 下拉框复选 包括全选
- radio单选框彩色,自定义边框,圆点颜色和大小
- 自定义checkbox和radio样式 圆形方形...
- select下拉菜单带图片