怎么用JS来控制<select>那个项目选项定
<form method= "post " name= "form ">
<input type= "text " name= "temp " size= "30 ">
<select name= "Class_1 " style= "width:80px " onchange= "temp.value=this.value ">
</select>
</form>
<script LANGUAGE= "javascript ">
document.form.Class_1.length = 0;
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王一蛋 ', '1 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王二蛋 ', '2 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王三蛋 ', '3 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王四蛋 ', '4 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王五蛋 ', '5 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王六蛋 ', '6 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王七蛋 ', '7 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王八蛋 ', '8 ');
/////////这句应该怎么写才能让王七蛋处理选定状态(不要index值控制)//////////
document.form.Class_1.options.text[ '王七蛋 '].selected=true;
//////////////////////////////
</script>
------解决方案--------------------没有明白啥意思啊?
是不是这个啊?
大概是 当选中的值是7, 显示王七蛋 待选嘛?
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王七蛋 ', '7 ');
大概这样吧,
if Class_1.value==7,让这个 new Option( '王七蛋 ', '7 ');设为 selected就行了,
------解决方案---------------------------------
自动选取一个
-------------
随机选取?
上页传值?
不知道lz要干什么啊?
------解决方案-------------------- <form method= "post " name= "form ">
<input type= "text " name= "temp " size= "30 ">
<select name= "Class_1 " style= "width:80px " onchange= "temp.value=this.value ">
</select>
</form>
<script LANGUAGE= "javascript ">
document.form.Class_1.length = 0;
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王一蛋 ', '1 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王二蛋 ', '2 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王三蛋 ', '3 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王四蛋 ', '4 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王五蛋 ', '5 ');
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王六蛋 ', '6 ');
var x=new Option( '王七蛋 ', '7 ');
document.form.Class_1.options[document.form.Class_1.length] = x;
document.form.Class_1.options[document.form.Class_1.length] = new Option( '王八蛋 ', '8 ');
/////////这句应该怎么写才能让王七蛋处理选定状态(不要index值控制)//////////
//document.form.Class_1.options.text[ '王七蛋 '].selected=true;
x.selected=true;
//////////////////////////////
</script&g