codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Validating Radio Button  sanny6136 at 07:03 on Monday, May 22, 2006
 

Hi Guys,

i have dynamic radio buttons i want to write script to select anyone of the radio button

a sample code as follows:

for(int i=0;i<=100;i++)
{%>
<input type="radio" value="10" name="cb<%=i++%>">Always
<input type="radio" value="9" name="cb<%=i++%>">Sometimes
<input type="radio" value="8" name="cb<%=i++%>">Rarely
<input type="radio" value="7" name="cb<%=i++%>">Never</td>
<%}%>
inthis i want to select atleast one radio button for each i value.

anysuggstions

Thanks in advance
Sanny

  Re: Validating Radio Button  hemangkapadia at 08:42 on Thursday, July 27, 2006
 

Hi,
Give a same name to the radio button instead of cb1,cb2.... and so on,it will automatically create an array and then u can check whether any of those is checked or not by usinfg thsi function
and passing obj as document.forms[0].cb
function checkRadio(obj)
{
for (var i=0;i<obj.length;i++)
{
if(obj.checked)
{
return true;
}

}
return false;
}










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Why does my menu have specks?
•  moving mouse on the line graph
•  disconnected data
•  DHTML with Active X & codesigning
•  toggling between multiple layers.
•  Restricting a user from selecting a Entry in the Combo box
•  Need a dialog box while downloading a file from IE
•  Script won`t play in Internet Explorer
•  How to write into the STDIN?


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2006