Jump to content

Requiring a checkbox from array of values


lala

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.