Howdy.
I think you'll need to count selected checkboxes, and then
test the count. For example:
cnt = 0;
for (i=0; i<document.forms[0].batchdeletes.length; i++) {
if(document.forms[0].batchdeletes[i].checked){
cnt = cnt + 1;
}
}
if (cnt > 0){
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;
}
}else{
alert('You must select at least one checkbox');
return false;
}
Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
>-----Original Message-----
>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(){
> > 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>
>
>
>
>
>.
>