[Javascript] IE/FF, getElementById and checkboxes

Alan Easton alaneaston666 at hotmail.com
Wed Apr 30 18:48:18 CDT 2008


Hi All,
 
I have some validation that works in IE, for when I need to check if any checkboxes are checked in my form. If there are, then I submit the form.
 
Code is below:
 
------------------------------------------------
 
<script language="JavaScript">
function delArts()
{
var i,sel;
sel = 0;
for(i = 0; i < actform.delusers.length; i++)    <----THIS LINE
{
if(actform.delusers(i).checked)                    <---THIS LINE
{
sel = 1;
}
}
if(sel != 1)
{
alert("Deletion of Users\n\nYou must first select some users to delete.");
}
else
{
if(confirm("Are you sure you wish to delete these users?"))
{
actform.submit();
}
}
}
</script>
 
Example checkbox field:
<input type="checkbox" value="5" name="delusers">
 
All are called "delusers", and have different values. Now I know I need to ad "id"'s to all of these, but I am still having trouble.
 
------------------------------------------------
 
However this is not working in FF. I know I need to change to use getElementById, but the two lines highlighted above are causing me problems.
 
Any help would be appreciated in order so the validation works in IE and Ff.
 
Thanks,
 
Alan...
 
 
 
 
 
_________________________________________________________________
Play the Andrex Hello Softie Game & win great prizes 
http://www.thehellosoftiegame.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20080501/d5512ca1/attachment.htm>


More information about the Javascript mailing list