联动问题!!!要多少分,尽管开口。 http://fason.nease.net/samples/bigarea/请到以上网址进行下载. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <select onchange="ch(this);"> <option value="中国">中国</option> .....</select><script language=javascript>function ch(obj){ if (this.value=='中国') obj.form.sel2.options[0].selected=true; .................}</script> http://community.csdn.net/Expert/topic/3198/3198380.xml?temp=.5498773 mjpclab(我是大猫猫啊 http://mjpclab.8u8.com):我的意思是怎么把数据库里的值 ,赋给联动下拉框。 还是你啊?String(objRs("vdata"))是你的value,那么你的s2.value="<%=objRs("vdata")%>"也要用这个,不是text了明白不? [text,value] 阿信:那个贴子我看过了,不行啊。你的方法是不是:在修改页面里添加了test()函数,在body onload事件里调用test()。test()函数中引用的form名称也修改成自己的form名称,别的还有什么需要改的。s1.value赋值,赋字符串,赋记录集的域值都试过。不行啊附函数:function test(){ with(document.demoform){ s1.value="网络"; s1.onchange(); s2.value="稳定性"; s2.onchange(); } } 我赋字符串,只是测试用,真实值是从库里取的。我显示的是VALUE啊 显示出来的是text,值是value添加时add(key,[[text,value],[text,value]])这样添加s1.value=".."这个是你数据库value的值,不是text,如"广东"对应001,001是你的value http://www.changshainvest.gov.cn/myblog/blogview.asp?logID=49&cateID=2 你到底想实现什么样的结果.. fason(Forbes Pu) ( ) 信誉:700 回答的很明白了..他可是这里面的元老级人物.. selectIndex = ???or for (var i=0; i<selectname.length; i++){ if (selectname.options[i].value == ???) { selectname.selectIndex = i; break; }} <script language="javascript">//定义城市数组,可以从数据库动态定义city_array = new Array();city_array[0] = new Array("1","1","杭州");city_array[1] = new Array("3","1","南京");function change(){ //删除原先城市下拉框的内容 document.form.city.length = 0; //加入新的内容 document.form.city.options[document.form.city.length]=new Option("所有城市",0); pro_value = document.form.pro.options[document.form.pro.selectedIndex].value; if (pro_value != "0"){ for (i = 0;i < city_array.length;i++){ if (city_array[i][0] == pro_value){ document.form.city.options[document.form.city.length]=new Option(city_array[i][2],city_array[i][1]); } } }}</script><form name ="form"> <select name="pro" onchange="change();"> <option value="1">所有省份</option> <option value="1">浙江</option> <option value="2">上海</option> <option value="3">江苏</option> </select> <select name="city"> <option value="1">所有城市</option> </select></form> 分数你自己看着给 //处理级联式下拉 function selectRelationInit(num){ var i,j,arrTemp=[]; //保存当前的选择项 for(i=0;i<num;i++) arrTemp[i]=document.all(arrSel[i]).options[document.all(arrSel[i]).selectedIndex].text; if(num==arrSel.length){//如果处理到了最后一级则退出 return; } with(document.all(arrSel[num])) { length=0; for(i=0;i<arrData.length;i++) { for(j=0;j<num;j++) if(arrTemp[j]!=arrData[i][j]) break; if(j!=num) continue; if(length==0||options[length-1].text!=arrData[i][num]) { options[length++] = new Option(arrData[i][num],arrDataValue[i][num]); } } onchange=new Function("selectRelationInit("+(num+1)+")"); selectRelationInit(num+1) }}//执行初始化selectRelationInit(0);//初始化 我想写一个xml的联动给你,不知你想要不? 各位大神 帮帮忙。。。 web跟随鼠标的文字我不行啊!需要你帮助 选色器问题 JS高人帮帮忙:计算时间差问题 我的Cookie的值怎么读呢?用网上的方法不对呢 简单的语法问题。送分了。 各位大虾,请过来看看。怎么实现ASP动态页面的全屏??? 情已逝,您人别走呀! 昨天的问题请孟斑竹帮忙再解决以下,那个方法有个小bug 小白求大神指点 关于JavaScript中处理时间的问题? js窗口问题
<option value="中国">中国</option>
.....
</select><script language=javascript>
function ch(obj)
{
if (this.value=='中国') obj.form.sel2.options[0].selected=true;
.................
}
</script>
我的意思是怎么把数据库里的值 ,赋给联动下拉框。
String(objRs("vdata"))是你的value,那么你的s2.value="<%=objRs("vdata")%>"
也要用这个,不是text了明白不? [text,value]
那个贴子我看过了,不行啊。你的方法是不是:
在修改页面里添加了test()函数,在body onload事件里调用test()。test()函数中引用的form名称也修改成自己的form名称,别的还有什么需要改的。
s1.value赋值,赋字符串,赋记录集的域值都试过。不行啊附函数:
function test()
{
with(document.demoform){
s1.value="网络";
s1.onchange();
s2.value="稳定性";
s2.onchange(); }
}
添加时add(key,[[text,value],[text,value]])这样添加
s1.value=".."这个是你数据库value的值,不是text,如"广东"对应001,001是你的value
fason(Forbes Pu) ( ) 信誉:700 回答的很明白了..他可是这里面的元老级人物..
{
if (selectname.options[i].value == ???)
{
selectname.selectIndex = i;
break;
}
}
//定义城市数组,可以从数据库动态定义
city_array = new Array();
city_array[0] = new Array("1","1","杭州");
city_array[1] = new Array("3","1","南京");function change(){
//删除原先城市下拉框的内容
document.form.city.length = 0;
//加入新的内容
document.form.city.options[document.form.city.length]=new Option("所有城市",0);
pro_value = document.form.pro.options[document.form.pro.selectedIndex].value;
if (pro_value != "0"){
for (i = 0;i < city_array.length;i++){
if (city_array[i][0] == pro_value){
document.form.city.options[document.form.city.length]=new Option(city_array[i][2],city_array[i][1]);
}
}
}
}
</script>
<form name ="form">
<select name="pro" onchange="change();">
<option value="1">所有省份</option>
<option value="1">浙江</option>
<option value="2">上海</option>
<option value="3">江苏</option>
</select>
<select name="city">
<option value="1">所有城市</option>
</select>
</form> 分数你自己看着给
function selectRelationInit(num){
var i,j,arrTemp=[];
//保存当前的选择项
for(i=0;i<num;i++)
arrTemp[i]=document.all(arrSel[i]).options[document.all(arrSel[i]).selectedIndex].text;
if(num==arrSel.length){//如果处理到了最后一级则退出
return;
}
with(document.all(arrSel[num]))
{
length=0;
for(i=0;i<arrData.length;i++)
{
for(j=0;j<num;j++)
if(arrTemp[j]!=arrData[i][j])
break;
if(j!=num)
continue;
if(length==0||options[length-1].text!=arrData[i][num])
{
options[length++] = new Option(arrData[i][num],arrDataValue[i][num]);
}
}
onchange=new Function("selectRelationInit("+(num+1)+")");
selectRelationInit(num+1)
}
}
//执行初始化
selectRelationInit(0);//初始化