当前位置: 代码迷 >> ASP >> asp获取不用提交的单选按钮的值解决方案
  详细解决方案

asp获取不用提交的单选按钮的值解决方案

热度:261   发布时间:2012-02-29 16:44:10.0
asp获取不用提交的单选按钮的值
上面有两个单选按钮下面有个列表筐   选择不同单选按钮   列表筐里显示不同的值


------解决方案--------------------
<form name= "Form1 ">
<input type= "radio " name= "rad " onclick= "changesel(a); "> aaa
<input type= "radio " name= "rad " onclick= "changesel(b); "> bbb
<br>
<select name= "sel "> </select>
</form>
<script>
var a = new Array();
a[0] = new Array( "a1 ",0);
a[1] = new Array( "a2 ",1);
a[2] = new Array( "a3 ",2);

var b = new Array();
b[0] = new Array( "b1 ",0);
b[1] = new Array( "b2 ",1);
b[2] = new Array( "b3 ",2);
changesel(a);

function changesel(arr){
var sel = document.Form1.sel;
while (sel.length > 0) {
sel.remove(sel.length - 1);
}
for (var i = 0; i < arr.length; i++) {
var opt = document.createElement( "OPTION ");
sel.options.add(opt);
opt.innerText = arr[i][0];
opt.value = arr[i][1];

}
}
</script>
  相关解决方案