[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Radiobuttonlist client side javascript question

Posted on 2004-10-28
7
Medium Priority
?
4,966 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:Quintin79
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:ryerras
ID: 12440218
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");
0
 
LVL 1

Author Comment

by:Quintin79
ID: 12440232
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.  
0
 
LVL 15

Expert Comment

by:Thogek
ID: 12440298
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.)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:ryerras
ID: 12440309
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?
0
 
LVL 1

Author Comment

by:Quintin79
ID: 12440392
ryerras - yes.  that way i can loop thru it in javascript.
0
 
LVL 6

Accepted Solution

by:
ryerras earned 500 total points
ID: 12440548
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
0
 
LVL 1

Author Comment

by:Quintin79
ID: 12440817
oh man is that all i can do ?  thats a let down.  anyway thanks - your answer is the go.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question