whatId1为另一个RadioButtonList,whatId2为当前所点RadioButtonList
function getValueTwo(whatId1,whatId2)
{
var id1=whatId1;
var id2=whatId2;
var leth1=document.getElementById(id1).cells.length;
var leth2=document.getElementById(id2).cells.length;
var maybeSel1="";
var maybeSel2="";
var boolValue=false;
for(var i=0;i<leth2;i++)
{ //检查被点击的RadioButtonList是否被选中了,若没选中,那么原来的RadioButtonList将不会被取消选中。
maybeSel2 = id2+"_"+i;
if(document.getElementById(maybeSel2).checked)
{
boolValue=true
break;
}
}
if(boolValue)
{
for(var i=0;i<leth1;i++)
{
maybeSel1 = id1+"_"+i;
if(document.getElementById(maybeSel1).checked)
{
//点击一个RadioButtonList,利用另一个ID=whatId1的RadioButtonList取消whatId1的所选项。
document.getElementById(maybeSel1).checked=false;
break;
}
}
}
}
2个RadioButtonList之间实现单选
最新推荐文章于 2021-04-07 11:17:39 发布