Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating checkboxes...won't work in Netscape!

Status
Not open for further replies.

trojan800

Programmer
Nov 27, 2001
53
US
OK I have list/array of checkboxes created dynamically from a database (therefor all have the same name w/ different values) the checkboxes are created server-side vbscript like so:
Do Until objRS.EOF
Response.Write &quot;<TD><input type=&quot; & chr(34)& &quot;checkbox&quot; & chr(34) & &quot;name=&quot; & chr(34) & &quot;selReel&quot; & chr(34) & &quot;value=&quot; & objRS(&quot;ID&quot;) & &quot;>&quot; & vbCrLf
objRS.movenext
arraycount = arraycount + 1
Loop

//counter sent to javascript used to step through array in Verify Data function
Response.write &quot;<script> var arraycount = &quot; & arraycount & &quot;; </script>&quot;

//onSubmit calls function VerifyData
<form action=&quot;return.asp&quot; method=&quot;post&quot; name=&quot;FORM1&quot; onSubmit=&quot;return VerifyData()&quot;>


function VerifyData()
{
var form = document.FORM1;
var i, j;

//if only one checkbox was created it only checks that one to see if it was checked
if (arraycount == 1)
{
if (form.selReel.checked == true)
{
return true;
}
}

//if more than it steps through the array of all checkboxes returning true when it finds one that has been selected
if (arraycount > 1)
{
for (i = 0; i < arraycount; i++)
{
if (form.selReel.checked == true)
{
return true;
}
}
}

alert (&quot;You must mark a box before submitting to database&quot;);
return false;


}

Everything works fine in IE (of course) but I am just not familiar enough with this stuff to get it to work in Netscape. Please somebody Help! TIA - Rory
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top