单击“删除”按钮后,如果未选中任何复选框,如何显示警报。我的html表单
<form name="Delete" method="post" action="DeleteAdministrator">
<table width="800px" cellpadding="5" style="color:black; border-top:1px solid #ccc;" border="0">
</table>
<div id="container">
<div id="demo_jui">
<table id="adminList" class="display" cellpadding="0" cellspacing="0" border="0" style="font-size:12px;" >
<thead id="headed">
<tr>
<th align="center" title="Select">Select</th>
<th align="center" title="Email Address">Email Address</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<table id="footed">
<tr>
<td colspan="2">
<a href="#"><img src="images/Delete.png" style="border:none;" onClick="javascript:Go()"
onmouseover="this.src='images/Delete_Hover.png'" onmouseout="this.src='images/Delete.png'"/></a>
<a href="#"><img src="images/Reset.png" style="border:none;" onClick="javascript:clearForm()"
onmouseover="this.src='images/Reset_Hover.png'" onmouseout="this.src='images/Reset.png'"/></a>
</td>
</tr>
</table>
</form>
</body>
</html>
复选框值将在表中检索。当我测试它时,当复选框被选中或未选中时,它仍然提醒“请选择删除管理员”
在功能Go()
中,验证方式document.Delete.delAdlist[i].checked
是否正确?谢谢
<script language="JavaScript">
var running = 0;
function Go() {
var f = document.forms[0];
for (i = 0; i < document.Delete.delAdlist.length) {
if (!document.Delete.delAdlist[i].checked) {
alert("Please select to delete admin.");
return false;
}
else {
f.submit();
return true;
}
}
f.submit();
running++;
}
</script>