表单radio,选中的JS事件,在线等答案
我有一个表单,如图代码如下:<form><table><tr> <td>&n...
我有一个表单,如图代码如下:<form><table><tr> <td> <p><input name="iq01" type="radio" id="r1-1" value="R" checked />R:</p> <p><input name="iq01" type="radio" id="r1-2" value="F" />F:</p> <p><input name="iq01" type="radio" id="r1-3" value="M" />M:</p> <p><input name="iq01" type="radio" id="r1-4" value="N" />N:</p> </td> <td> <p><input name="iq02" type="radio" id="r2-1" value="N" checked />N: Without Backlight</p> <p><input name="iq02" type="radio" id="r2-2" value="E" />E: </p> <p><input name="iq02" type="radio" id="r2-3" value="L" />L:</p> <p><input name="iq02" type="radio" id="r2-4" value="S" />S: </p> <p><input name="iq02" type="radio" id="r2-5" value="C" />C: </p> </td></tr></table></form> 预实现效果:1、当选择第一列选项值 R时,第二列E , L, S, C 全部禁用2、当选中第一列其它值时,第二列 N 禁用 如何实现?
展开
1个回答
展开全部
<form><table border=1><tr> <td> <p><input name="iq01" type="radio" id="r1-1" value="R" checked /
onclick="chkchg()">R:</p> <p><input name="iq01" type="radio" id="r1-2" value="F" / onclick="chkchg()">F:</p>
<p><input name="iq01" type="radio" id="r1-3" value="M" / onclick="chkchg()">M:</p> <p><input name="iq01" type="radio" id="r1-4"
value="N" / onclick="chkchg()">N:</p> </td> <td> <p><input name="iq02" type="radio" id="r2-1" value="N" checked />N: Without
Backlight</p> <p><input name="iq02" type="radio" id="r2-2" value="E" />E: </p> <p><input name="iq02"
type="radio" id="r2-3" value="L" />L:</p> <p><input name="iq02" type="radio" id="r2-4" value="S" />S: </p>
<p><input name="iq02" type="radio" id="r2-5" value="C" />C: </p> </td></tr></table></form>
<script language="javascript">
function chkchg(){
var arr=document.getElementsByName("iq02");
if(document.getElementById("r1-1").checked==false){
for ( i = 0; i < arr.length; i++) {
arr[i].disabled=true;
}
}
else{
for ( i = 0; i < arr.length; i++) {
arr[i].disabled=false;
}
}
}
</SCRIPT>
onclick="chkchg()">R:</p> <p><input name="iq01" type="radio" id="r1-2" value="F" / onclick="chkchg()">F:</p>
<p><input name="iq01" type="radio" id="r1-3" value="M" / onclick="chkchg()">M:</p> <p><input name="iq01" type="radio" id="r1-4"
value="N" / onclick="chkchg()">N:</p> </td> <td> <p><input name="iq02" type="radio" id="r2-1" value="N" checked />N: Without
Backlight</p> <p><input name="iq02" type="radio" id="r2-2" value="E" />E: </p> <p><input name="iq02"
type="radio" id="r2-3" value="L" />L:</p> <p><input name="iq02" type="radio" id="r2-4" value="S" />S: </p>
<p><input name="iq02" type="radio" id="r2-5" value="C" />C: </p> </td></tr></table></form>
<script language="javascript">
function chkchg(){
var arr=document.getElementsByName("iq02");
if(document.getElementById("r1-1").checked==false){
for ( i = 0; i < arr.length; i++) {
arr[i].disabled=true;
}
}
else{
for ( i = 0; i < arr.length; i++) {
arr[i].disabled=false;
}
}
}
</SCRIPT>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询