Link to home
Start Free TrialLog in
Avatar of Quintin79
Quintin79

asked on

Radiobuttonlist client side javascript question

OK

in HTML if i want to find the length or loop through an array of radio buttons in the browser i can usually go document.getElementById("arrayName").length;  cant I?

when you create a radiobuttonlist in asp.net it creates the correct radio tags on client side but it also surrounds them in a table with the same name.  you know that by naming the radios all the same it creates an array of the radios but asp.net throws in a table of the same name and i cant seem to access the radio buttons.

when i go document.getElementById("arrayName") it returns the table and therefore i cant get the radios.

any ideas on how to sort this one out

thanks in advance
Avatar of ryerras
ryerras

hmm. If you open the View Source for the web page, you would see that, asp.net generates unique id's for each radio button in the list, and they will be in certain order. If your radioButtonList id is "arrayName", then lets say you have 3 radio buttons in the list, then the id's will be "arrayName_0", "arrayName_1" and "arrayName_2".

So to access the first radio button, you should use document.getElementById("arrayName_0");
Avatar of Quintin79

ASKER

yes i know this and its the very last option.  the reason is that in most cases the radiobutton list will be of any size it wants so i wont know how many rb objects i have to loop through.  
Instead of
    document.getElementById("arrayName")
have you tried
    document.forms[0].arrayName
?  (Might need to check the client-side View Source to verify the common radio button name -- that's name, not ID -- for this.)
I do not understand your question. What do you want to achieve? Length of the radio buttonlist, you mean how many radio buttons in the list?
ryerras - yes.  that way i can loop thru it in javascript.
ASKER CERTIFIED SOLUTION
Avatar of ryerras
ryerras

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oh man is that all i can do ?  thats a let down.  anyway thanks - your answer is the go.