菜鸟问题 高分求助!!!

icefox1234 2005-04-05 09:04:26
问题:我想做两个下拉列表菜单(select),一个选择的改变而触发另一个列表的内容改变。就象我选择了某个省份,第二个列表就会列出这个省份的地级市给予选择。

前提就是:两个下拉列表菜单的内容都是从数据库中读出来的。

拜托各位高手了。
...全文
120 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
lookatliu 2005-04-05
  • 打赏
  • 举报
回复
偶要开会了,有问题的话发短消息给偶吧
lookatliu 2005-04-05
  • 打赏
  • 举报
回复
加油~~
icefox1234 2005-04-05
  • 打赏
  • 举报
回复
谢谢各位啊,正在调试
lookatliu 2005-04-05
  • 打赏
  • 举报
回复
SetDataComboBox里面的switch的case是部门,每个部门里面insertSelect人员
lookatliu 2005-04-05
  • 打赏
  • 举报
回复
看下下面的函数你能用不
function InsertSelect(objSel,strValue,strText)
{
var newOpt = document.createElement("OPTION");

newOpt.text = strText;
newOpt.value = strValue;
objSel.options.add(newOpt);
}

function SetDataComboBox(intSelVal,ComboBoxData,flag)
{
switch (intSelVal.toString())
{
case "6":
InsertSelect(ComboBoxData,"a","aaa");
InsertSelect(ComboBoxData,"b","bbb");
InsertSelect(ComboBoxData,"c","ccc");
break;
case "8":
InsertSelect(ComboBoxData,"d","ddd");
InsertSelect(ComboBoxData,"e","eee");
InsertSelect(ComboBoxData,"f","fff");
break;
default:
break;
}
}

function ChangeItem(ComboBoxItem,ComboBoxData,flag)
{
var intLen = ComboBoxData.length;
var intSelVal
var newOpt
for( i = intLen; i > 0 ; i--)
{
ComboBoxData.remove(i - 1);
}

intSelVal = ComboBoxItem.options[ComboBoxItem.selectedIndex].value

SetDataComboBox(intSelVal,ComboBoxData,flag)
}
icefox1234 2005-04-05
  • 打赏
  • 举报
回复
部门20个 人员300 不多 。求教方法!!
baisun 2005-04-05
  • 打赏
  • 举报
回复
要完成此效果把如下代码加入到<body>区域中

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();

arrItems1[3] = "Truck";
arrItemsGrp1[3] = 1;
arrItems1[4] = "Train";
arrItemsGrp1[4] = 1;
arrItems1[5] = "Car";
arrItemsGrp1[5] = 1;

arrItems1[6] = "Boat";
arrItemsGrp1[6] = 2;
arrItems1[7] = "Submarine";
arrItemsGrp1[7] = 2;

arrItems1[0] = "Planes";
arrItemsGrp1[0] = 3;
arrItems1[1] = "Ultralight";
arrItemsGrp1[1] = 3;
arrItems1[2] = "Glider";
arrItemsGrp1[2] = 3;

var arrItems2 = new Array();
var arrItemsGrp2 = new Array();

arrItems2[21] = "747";
arrItemsGrp2[21] = 0
arrItems2[22] = "Cessna";
arrItemsGrp2[22] = 0

arrItems2[31] = "Kolb Flyer";
arrItemsGrp2[31] = 1
arrItems2[34] = "Kitfox";
arrItemsGrp2[34] = 1

arrItems2[35] = "Schwietzer Glider";
arrItemsGrp2[35] = 2

arrItems2[99] = "Chevy Malibu";
arrItemsGrp2[99] = 5
arrItems2[100] = "Lincoln LS";
arrItemsGrp2[100] = 5
arrItems2[57] = "BMW Z3";
arrItemsGrp2[57] = 5

arrItems2[101] = "F-150";
arrItemsGrp2[101] = 3
arrItems2[102] = "Tahoe";
arrItemsGrp2[102] = 3

arrItems2[103] = "Freight Train";
arrItemsGrp2[103] = 4
arrItems2[104] = "Passenger Train";
arrItemsGrp2[104] = 4

arrItems2[105] = "Oil Tanker";
arrItemsGrp2[105] = 6
arrItems2[106] = "Fishing Boat";
arrItemsGrp2[106] = 6

arrItems2[200] = "Los Angelas Class";
arrItemsGrp2[200] = 7
arrItems2[201] = "Kilo Class";
arrItemsGrp2[201] = 7
arrItems2[203] = "Seawolf Class";
arrItemsGrp2[203] = 7

function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "[SELECT]" ;
controlToPopulate.add(myEle) ;
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
</script>
<form name=myChoices>
<table align="center">
<tr>
<td>
<SELECT id=firstChoice name=firstChoice onchange="selectChange(this, myChoices.secondChoice, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>[SELECT]</option>
<option value=1>Land</option>
<option value=2>Sea</option>
<option value=3>Air</option>
</SELECT>
</TD><TD>
<SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thirdChoice, arrItems2, arrItemsGrp2);">
</SELECT>
<SELECT id=thirdChoice name=thirdChoice>
</SELECT>
</TD>
</TR>
</TABLE>
</form>
lookatliu 2005-04-05
  • 打赏
  • 举报
回复
数据不多的话就全读出来,生成javascript啊
icefox1234 2005-04-05
  • 打赏
  • 举报
回复
你得告诉我啊,大哥!!!
sansaolu 2005-04-05
  • 打赏
  • 举报
回复
這很簡單呀﹗﹗﹗﹗﹗﹗﹗﹗﹗﹗
icefox1234 2005-04-05
  • 打赏
  • 举报
回复
顶一顶!!!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧