M
Mark
Hi,
I use javascript to force the user to
click checkbox when they click submit.
It works well when checkbox is more
than one. If only one checkbox, it doesn't
want me go through. I think my javascript
has some logic problem. but I don't know
how to modify it. Anyone can help me.
Thanks,
<html>
<head>
<title>Delete</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function DeleteInventory(){
for (var i=0; i<document.forms[0].batchdeletes.length; i++) {
if(document.forms[0].batchdeletes.checked){
if (confirm("This will delete Inventories you selected!")){
document.forms[0].action = "http://www.yahoo.com";
document.forms[0].submit();
return true;
}
else{
return false;
}
}
}
alert('You must check the checkbox');
return false;
}
// -->
</SCRIPT>
</head>
<body>
<form name="delete_inv" method="POST">
<p>
<input type="checkbox" name="batchdeletes" value="A123"><br>
<!--input type="checkbox" name="batchdeletes" value="A124"--><br>
<!--input type="checkbox" name="batchdeletes" value="A125"--><br>
<input type=button name=deletebutton value="Delete Selected Inventories"
onclick="return DeleteInventory();">
</p>
</form>
</body>
</html>
I use javascript to force the user to
click checkbox when they click submit.
It works well when checkbox is more
than one. If only one checkbox, it doesn't
want me go through. I think my javascript
has some logic problem. but I don't know
how to modify it. Anyone can help me.
Thanks,
<html>
<head>
<title>Delete</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function DeleteInventory(){
for (var i=0; i<document.forms[0].batchdeletes.length; i++) {
if(document.forms[0].batchdeletes.checked){
if (confirm("This will delete Inventories you selected!")){
document.forms[0].action = "http://www.yahoo.com";
document.forms[0].submit();
return true;
}
else{
return false;
}
}
}
alert('You must check the checkbox');
return false;
}
// -->
</SCRIPT>
</head>
<body>
<form name="delete_inv" method="POST">
<p>
<input type="checkbox" name="batchdeletes" value="A123"><br>
<!--input type="checkbox" name="batchdeletes" value="A124"--><br>
<!--input type="checkbox" name="batchdeletes" value="A125"--><br>
<input type=button name=deletebutton value="Delete Selected Inventories"
onclick="return DeleteInventory();">
</p>
</form>
</body>
</html>