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 :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.