To check a radio

B

Bob

Hi at all

I have a radio group with 3 options

<input type="radio" value first" name="first" id="choices">

<input type="radio" value="second" name="second" id="choices">

<input type="radio" value="three" name="three" id="choices">

Is it possible to check the second using getelementbyid?

How?

Thank in advance
 
D

David Mark

Hi at all

I have a radio group with 3 options

<input type="radio" value first" name="first" id="choices">

<input type="radio" value="second" name="second" id="choices">

<input type="radio" value="three" name="three" id="choices">

Is it possible to check the second using getelementbyid?

You seem to be confused in a couple of ways. ID's must be unique.
Form element names do not. A radio group with different names for
each button is useless.

Give it a unique id. Then you can find it with gEBI and set its
checked property.
 
R

rf

Bob said:
Hi at all

I have a radio group with 3 options

<input type="radio" value first" name="first" id="choices">

<input type="radio" value="second" name="second" id="choices">

<input type="radio" value="three" name="three" id="choices">

Is it possible to check the second using getelementbyid?

How?

If these radio buttons really are part of a group then they all should have
the same name. That is how grouped radio buttons work.

http://www.w3.org/TR/html401/interact/forms.html#radio

id must be unique within a document.

http://www.w3.org/TR/html401/struct/global.html#adef-id

<input type="radio" name="choice" value="first" id="first">
<input type="radio" name="choice" value="second" id="second">
<input type="radio" name="choice" value="third" id="third">

With valid HTML the problem disappears, but you would have to use
getElementById.
 
B

Bob

-z54uj
My problem is different

In a certain point of a HTML page I have a radio group

with 3 radio button

At an other point of the page I have an <input type=text

If the user enter a certain value I want to check the second radio button.
 
R

rf

Bob said:
My problem is different

Different to what?
In a certain point of a HTML page I have a radio group

with 3 radio button

No you don't. Not if you are referring to that code you posted. You have
three totally unrelated radio buttons.
At an other point of the page I have an <input type=text
Fine.

If the user enter a certain value I want to check the second radio button.

Then you will access it via getElementById, with it's unique id, just like I
showed you.

Did you read those references I gave you?
 
T

Thomas 'PointedEars' Lahn

David said:
Give it a unique id. Then you can find it with gEBI and set its
checked property.

Or, more compatible, use the common iteration approach.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top