<div id="pop2" class="box2" style="display: none">
<form action="" method="post">
<div class="second" style="margin-top:3px;margin-left:10px;font-size:100%">Add to</div>
<?php
$new2=array();
$new2=getlist();
foreach($new2 as $value){
echo'<input type="radio" id="qwerty" name="qwerty" value="'.$value.'" onclick="theLast()" />';
echo"$value";echo"<br>";}
?>
<hr>
<button type="button" id="add2" class="new" onclick="theFinal()" >Create new list</button>
</form>
</div>
和我使用javascript检查在theLast()函数
if (document.getElementById('qwerty').checked) {
window.lists=document.getElementById('qwerty').value;
}
只有第一个单选按钮工作正常,其余的在。checked()中没有检测到
为所有复选框使用相同的id
属性可能会导致这些问题。我建议使用一个通用类,并使用getElementByClassName函数迭代复选框,以检查"已选中"框。