xecutioner Posted March 31, 2011 Share Posted March 31, 2011 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 https://forums.phpfreaks.com/topic/232283-validating-dynamically-generated-radio-buttons/ Share on other sites More sharing options...
xecutioner Posted March 31, 2011 Author Share Posted March 31, 2011 Leme add something .. script is working but it is returning false if one radio button is generated. It works perfectly fine for a group of radio buttons(2 or more radio buttons) Help please Link to comment https://forums.phpfreaks.com/topic/232283-validating-dynamically-generated-radio-buttons/#findComment-1194917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.