假设现在有两个RadioButtonList分别为RadioButtonList1和RadioButtonList2
其中RadioButtionList1中有4个选项A,B,C,D
我希望每当选中D时,触发javascript方法,使RadioButtonList2不可使用
应该怎么做?
要使用RadioButtonList这个控件的.
asp.net如何用javascript来捕捉某个RadioButtonList的触发?
答案:3 悬赏:10 手机版
解决时间 2021-03-17 16:15
- 提问者网友:謫仙
- 2021-03-17 00:05
最佳答案
- 五星知识达人网友:孤老序
- 2021-03-17 01:25
<script> <br>function check(nameStr) <br>{ <br>var keys = "A,B,C"; <br>var nokey = ""; <br>var arrkey = new Array(); <br>for(var i = 0; i < 3; i++) <br>{ <br>if(getRadio(nameStr+ String(i + 1)) != "") <br>{ <br>arrkey[i] = getRadio(nameStr + String(i + 1)); <br>} <br>else <br>{ <br>nokey = nokey + String(i + 1) <br>} <br>} <br>if(nokey == "") <br>{ <br>alert("正确答案:" + keys + "\n" + "你的答案:" + arrkey.join(",")); <br>} <br>else <br>{ <br>alert("未做题号:" + nokey); <br>} <br>} <br>function getRadio(obj) <br>{ <br>var key = ""; <br>var obj = document.getElementsByName(obj); <br>for(var i = 0; i < obj.length; i++) <br>{ <br>if(obj[i].checked == true) <br>{ <br>key = obj[i].value; <br>} <br>} <br>return key; <br>} <br></script> <br><br><input type="radio" name="q1" value="A">a1 <br><input type="radio" name="q1" value="B">a2 <br><input type="radio" name="q1" value="C">a3 <br><input type="radio" name="q1" value="D">a4 <br><br> <br><input type="radio" name="q2" value="A">b1 <br><input type="radio" name="q2" value="B">b2 <br><input type="radio" name="q2" value="C">b3 <br><input type="radio" name="q2" value="D">b4 <br><br> <br><input type="radio" name="q3" value="A">c1 <br><input type="radio" name="q3" value="B">c2 <br><input type="radio" name="q3" value="C">c3 <br><input type="radio" name="q3" value="D">c4 <br><br> <br><input type="button" value="Check" onclick="check('q')">
全部回答
- 1楼网友:你哪知我潦倒为你
- 2021-03-17 03:51
<script> <br>function check(namestr) <br>{ <br>var keys = "a,b,c"; <br>var nokey = ""; <br>var arrkey = new array(); <br>for(var i = 0; i < 3; i++) <br>{ <br>if(getradio(namestr+ string(i + 1)) != "") <br>{ <br>arrkey[i] = getradio(namestr + string(i + 1)); <br>} <br>else <br>{ <br>nokey = nokey + string(i + 1) <br>} <br>} <br>if(nokey == "") <br>{ <br>alert("正确答案:" + keys + "\n" + "你的答案:" + arrkey.join(",")); <br>} <br>else <br>{ <br>alert("未做题号:" + nokey); <br>} <br>} <br>function getradio(obj) <br>{ <br>var key = ""; <br>var obj = document.getelementsbyname(obj); <br>for(var i = 0; i < obj.length; i++) <br>{ <br>if(obj[i].checked == true) <br>{ <br>key = obj[i].value; <br>} <br>} <br>return key; <br>} <br></script> <br><br><input type="radio" name="q1" value="a">a1 <br><input type="radio" name="q1" value="b">a2 <br><input type="radio" name="q1" value="c">a3 <br><input type="radio" name="q1" value="d">a4 <br><br> <br><input type="radio" name="q2" value="a">b1 <br><input type="radio" name="q2" value="b">b2 <br><input type="radio" name="q2" value="c">b3 <br><input type="radio" name="q2" value="d">b4 <br><br> <br><input type="radio" name="q3" value="a">c1 <br><input type="radio" name="q3" value="b">c2 <br><input type="radio" name="q3" value="c">c3 <br><input type="radio" name="q3" value="d">c4 <br><br> <br><input type="button" value="check" onclick="check('q')">
- 2楼网友:千杯敬自由
- 2021-03-17 02:19
abcd四个选项的值要不一样,
然后就是在代码里写OnClient事件了,别的参考有代码的哪位。
也可以用js直接给list1注册一个change事件,如果id不确定,可以用class来定位。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯