Radiobuttonlist client side javascript question


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 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 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
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

ryerrasConnect With a Mentor Commented:
hmm ok. Nothing cant be done in javascript, use this following two lines to find the length of the tables, when i say length of the table, that is number of rows,

var rbListTable = document.getElementById("RadioButtonList1").childNodes[0];
var tableRows = rbListTable.childNodes;
var tabLen= tableRows.length

After you get that, you know what you have to do, loop through from 0 to tabLen-1
hmm. If you open the View Source for the web page, you would see that, 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");
Quintin79Author Commented:
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.  
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Instead of
have you tried
?  (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?
Quintin79Author Commented:
ryerras - yes.  that way i can loop thru it in javascript.
Quintin79Author Commented:
oh man is that all i can do ?  thats a let down.  anyway thanks - your answer is the go.
All Courses

From novice to tech pro — start learning today.