lala Posted January 29, 2010 Share Posted January 29, 2010 I've got a simple form, returning an array of values, based on a user entered email address. The user then selects his/her registration, and submits the selection, allowing them to then update their registration. The problem is that when there's only one registration matching the email address, the JS validator doesn't recognize that the user has checked the box. When there's a list of choices, and the user selects one, the script allows the form to be processed. Here's the script: <script language="JavaScript"> <!-- function verifySubmit (Contact_Name) { var themessage = "Please enter the following missing information: "; chosen = "" len = document.form.Contact_Name.length for (i = 0; i <len; i++) { if (document.form.Contact_Name.checked) { chosen = document.form.Contact_Name.value } } if (chosen == "") { themessage = themessage + "\n\t Please select a registration"; } if (themessage == "Please enter the following missing information: ") { return true; } else { alert(themessage); return false; } } And the form: while ($row = mysql_fetch_array($result)) { ?> <tr> <td align="left"><input type="hidden" name="Number" value="<?=$row[0]?>" /> </td> <td align="left"><input type="checkbox" name="Contact_Name" value="<?=$row[2]?>" /><?=$row[2]?></td> <td align="left"><?=$row[3]?></td> <td align="left"><?=$row[9]?></td> <td align="left"><?=$row[10]?></td> </tr> //--> </script> Please help! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/190190-requiring-a-checkbox-from-array-of-values/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.