我有几个复选框,每个组仅与一个可选构件。 复选框的一个实例是如下所示:
<label class="checkbox inline">
<input type="checkbox" id="question1option1" name="question1options" value="correct" onclick="SingleSelect('question1option',this)"> 1
</label>
<label class="checkbox inline">
<input type="checkbox" id="question1option2" name="question1options" value="wrong" onclick="SingleSelect('question1option',this)"> 2
</label>
<label class="checkbox inline">
<input type="checkbox" id="question1option3" name="question1options" value="wrong" onclick="SingleSelect('question1option',this)"> 3
</label>
<label class="checkbox inline">
<input type="checkbox" id="question2option1" name="question2options" value="correct" onclick="SingleSelect('question2option',this)"> 1
</label>
<label class="checkbox inline">
<input type="checkbox" id="question2option2" name="question2options" value="wrong" onclick="SingleSelect('question2option',this)"> 2
</label>
<label class="checkbox inline">
<input type="checkbox" id="question2option3" name="question2options" value="wrong" onclick="SingleSelect('question2option',this)"> 3
</label>
我有翻出哪个单选按钮被路过的单选按钮组(下)选择一个JavaScript函数,是有一个相当于有人可以帮助我得到选中的复选框中的值(各只有一个“组”中)以类似的方式吗?
function getRadioValue (theRadioGroup)
{
for (var i = 0; i < document.getElementsByName(theRadioGroup).length; i++)
{
if (document.getElementsByName(theRadioGroup)[i].checked)
{
return document.getElementsByName(theRadioGroup)[i].value;
}
}
}
提前致谢。