我想在onclientclick之后运行我的onclick事件,但程序会一直弹出并询问请选择至少一个删除,无论是否单击我的复选框。
我想也许我的回报价值不对?谢谢你的帮助。
<script type="text/javascript">
function validate() {
var gridView = document.getElementById("<%=grid1.ClientID %>");
var checkBoxes = gridView.getElementsByTagName("input");
for (var i = 0; i < checkBoxes.length; i++) {
if (checkBoxes[i].checked) {
if (confirm("Are you sure to delete?")) {
alert("Ok");
}
}
else{
alert("Please select at least one to delete.");
return false;
}
return false;
}
}
</script>
答案 0 :(得分:1)
确认后退出该功能:
<script type="text/javascript">
function validate() {
var gridView = document.getElementById("<%=grid1.ClientID %>");
var checkBoxes = gridView.querySelectorAll("input[type='checkbox']");
for (var i = 0; i < checkBoxes.length; i++) {
if (checkBoxes[i].checked) {
if (confirm("Are you sure to delete?")) {
alert("Ok");
return true;
}
}
}
alert("Please select at least one to delete.");
return false;
}
</script>