Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript accessin of radio buutons???? Anyone??

Status
Not open for further replies.

WuCOng

Technical User
Apr 20, 2001
37
GB
I can't find my way round the IE DOM to read the value of a set of 5 radio buttons I have. They are all named "rooms" and have values from 1 to 5.

I need to compare the form with a predefined list of objects that are in an array. The script goes like this

for(i in place){
if(place.room==document.all.form1.rooms.????){
}
}

Where place.room is a property of my object and form1.rooms is an attempt to refer to the radio button set.

The other elements of form1 work fine but they are textboxes, select elements and checkboxes.

Does anyone know how to do this??

Thanks

WuCong
 
To find out the value, you just ask for:

document.form1.rooms.value

form1 being the name of your form, and rooms being the name of your set of radio buttons -- you can evaluate it like that with any expression --

This is assuming that you are running client side script on the same page that has the set of radio buttons...

If it's on a subsequent page, then the only way I check is to ask (in ASP) for request.form("rooms") to get the value that was checked when they hit 'Submit'

good luck! :)
Paul Prewett
 
Checking the value of a set of radio buttons does not seem to work correctly, even though it makes sense. The best way is to use:

document.form1.rooms[n].checked

Where 'n' is an integer from 0 to 1 less than the number of radio buttons in the set.

If you need to get the value, check if the radio button is checked and set a variable. Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top