This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes selecting a radio button for IE & Netscape Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "selecting a radio button for IE & Netscape" Watch "selecting a radio button for IE & Netscape" New topic
Author

selecting a radio button for IE & Netscape

ritchie diputado
Greenhorn

Joined: Sep 19, 2003
Posts: 5
How do you set the selection of the radio button that work both for IE and Netscape.
<form name="forname" action="any.do">
<input type="radio" name="obj" id="objID" value="0"></html:radio >
<input type="radio" name="obj" id="objID" value="1"></html:radio >
<input type="radio" name="obj" id="objID" value="2"></html:radio >
</form >

scenario: current selected radio is 0, i want to change the selection to 2 "changeRadio(2)"
thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

In the HTML or under Javascript control? And what version of Netscape? The answers you'll get will vary greatly with these answers.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ritchie diputado
Greenhorn

Joined: Sep 19, 2003
Posts: 5
Under javascript control. I want this to be as much as posible cross browser.
thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

The reference document.formname.obj will reference the radio group. This is a collection of the radio buttons.
So the following:

will set the second radio button as the selected button. (Note that this is an array index and has nothing to do with the values of the buttons).
hth,
bear
P.S. I know that this will work in all modern browsers.
[ September 23, 2003: Message edited by: Bear Bibeault ]
 
 
subject: selecting a radio button for IE & Netscape
 
Similar Threads
Select dinamically with radio buttons + indexed Form
One form, multiple radio button groups
setting a radio button
Using html:radio with indexed attribute
Creating Radio Buttons using Struts