<script type="text/javascript">
var CSelect = new Function("this.initialize.apply(this, Array.apply(null, arguments))");CSelect.prototype = {initialize : function (a, b) {
var wc = this;
wc.array = [];
wc.select = b;
a.onchange = function () {
var me = this;
wc.change.call(wc, me.options[me.selectedIndex].value);
};
},change : function (a) {
var wc = this, array = wc.array, o = wc.select, i;
o.options.length = 1;
for (i = 0 ; i < array.length ; i ++) {
if (array[i][0].toString() === a)
o.options[o.options.length] = new Option(array[i][2], array[i][1]);
}
},add : function (a, b, c) {
//a 为大类ID,b为小类ID,c为小类内容
var wc = this, array = wc.array;
array[array.length] = [a, b, c];
}};
</script><select id="SortId">
<option value="">选择大类</option>
<option value="0">搜索引擎</option>
</select><select id="TypeId">
<option value="" selected="selected">选择小类</option>
</select><script type="text/javascript">
(function () {
var wc = new CSelect(document.getElementById("SortId"), document.getElementById("TypeId"));
//ASP便利这里即可。
wc.add(0, 0, "百度");
wc.add(0, 1, "google");
wc = null;
})();
</script>
^o^
var CSelect = new Function("this.initialize.apply(this, Array.apply(null, arguments))");CSelect.prototype = {initialize : function (a, b) {
var wc = this;
wc.array = [];
wc.select = b;
a.onchange = function () {
var me = this;
wc.change.call(wc, me.options[me.selectedIndex].value);
};
},change : function (a) {
var wc = this, array = wc.array, o = wc.select, i;
o.options.length = 1;
for (i = 0 ; i < array.length ; i ++) {
if (array[i][0].toString() === a)
o.options[o.options.length] = new Option(array[i][2], array[i][1]);
}
},add : function (a, b, c) {
//a 为大类ID,b为小类ID,c为小类内容
var wc = this, array = wc.array;
array[array.length] = [a, b, c];
}};
</script><select id="SortId">
<option value="">选择大类</option>
<option value="0">搜索引擎</option>
</select><select id="TypeId">
<option value="" selected="selected">选择小类</option>
</select><script type="text/javascript">
(function () {
var wc = new CSelect(document.getElementById("SortId"), document.getElementById("TypeId"));
//ASP便利这里即可。
wc.add(0, 0, "百度");
wc.add(0, 1, "google");
wc = null;
})();
</script>
^o^
怎么取得request里边的对象呢??
能说具体些么?
也就是majorDivisionList使数据库查出来的大分类和小分类的结构然后在页面上生成大分类,小分类的级联菜单
你这什么语言。。不懂。。
(function () {
var wc = new CSelect(document.getElementById("SortId"), document.getElementById("TypeId"));
//ASP便利这里即可。
wc.add(0, 0, "百度");
wc.add(0, 1, "google");
wc = null;
})();
生成的时候。。
循环便利
wc.add(0, 1, "google");即可。。
具体方法。。
(function () {
var wc = new CSelect(document.getElementById("SortId"), document.getElementById("TypeId"));
<%...Asp若干多....
While Not rs.Eof%>
wc.add(<%=rs("大类ID").Value%>, <%=rs("小类ID").Value%>, "<%=rs("小类名字").Value%>");
<%...Asp若干多....
rs.MoveNext : Wend%>
wc = null;
})();这个是便利小类。。
然后在便利下大类。。<select id="SortId">
<option value="">选择大类</option>
<%...Asp若干多....
While Not rs.Eof%>
<option value="<%=rs("大类ID").Value%>">"<%=rs("大类名字").Value%>"</option>
<%...Asp若干多....
rs.MoveNext : Wend%>
</select>
多粘贴了个""
改成这样。。
<option value="<%=rs("大类ID").Value%>"><%=rs("大类名字").Value%></option>