|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hello, i'm having a problem with radio buttons in general in JavaScript. The problem is when a radio button has only one button the length parameter is undefined. Add another button to the radio button and this code will work fine.
<html> <body> <script type="text/javascript" language="javascript1.5"> function radioAlert() { alert("Length = " + document.form[0].uploadType.length); } </script> <form> Tutorial<input type="radio" name="uploadType" value="tutorial" onClick="radioAlert()"/><br /> </form> </body> </html> |
|
#2
|
||||
|
||||
|
Didn't know about this issue. I guess you assign the length attribute to a variable and then test the variable. If it's undefined/false/Nan/whatever, set it to 1; else set it to the value and use that in your alert.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
||||
|
||||
|
Isn't it document.forms[0], not form (singular)?
|
|
#4
|
||||
|
||||
|
Heh, good catch, stumpy.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Radio button length problem(bug?) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|