Jump to content

Validating dynamically generated radio buttons


xecutioner

Recommended Posts

Hi All,

 

I have been trying validating radio buttons that were generated dynamically for 2 days now. I can validate when a group of 2 or more than 2 radio buttons are created. But I am unable to validate if a single radio button is generated.

So this is where I am generating radio buttons

 

echo "<tr>"."<td class='tablewhitebg'>"."<input type = 'radio' name= 'userid' value= '".$userid. "'></td>"."<td class='tablewhitebg'>$userid</td><td class='tablewhitebg'>$userloginid</td><td class='tablewhitebg'>$fname</td><td class='tablewhitebg'>$surname</td><td class='tablewhitebg'>$locked</td><td class='tablewhitebg'>$mailbox</td><td class='tablewhitebg'>$domainid</td><td class='tablewhitebg'>$timestamp</td><td class='tablewhitebg'>$emailaddress</td><td class='tablewhitebg'>$classofservice</td></tr>\n";

 

Now this code is generating radio buttons, all is good but when i want to validate it using javascript, Its not working at all

 

<script>

function validate_form(thisform)

{

chosen = "";

 

len = document.form1.userid.length

 

        for (i = 0; i <len; i++) {

                if (document.form1.userid.checked)

                {

chosen = document.form1.userid.value;

                }

}

 

if (chosen == "") {

alert("Please select a record to go ahead!!");

return false;

}

 

}

</script>

 

Helps please :(

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.