File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Radio button array length = 0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Radio button array length = 0" Watch "Radio button array length = 0" New topic

Radio button array length = 0

Alicia Logan

Joined: Aug 24, 2005
Posts: 14
Hi All,

The problem is i am using radio element in my JSP page and depending upon the results, the page dynamically displays the no of radio buttons which equals the no of results. Now my requirement is that when a user selects one radio button and clicks on a button, the JS function looks for the radio button which is selected and returns the value of the same accordingly. But the problem is when the result is only '1' the array length is 0. Hence how do i overcome this situation to return the value of that radio as the value of array in this case i.e. document.forms[0].radioBtn.length is always undefined. I need something to check that only one radio button is present and then accordingly pass on the value of that radio button.

Thanks in advance
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385

I agree. Here's the link:
subject: Radio button array length = 0
It's not a secret anymore!