| Author |
how do i make a radio button to be checked when a page loads up?
|
kay lin
Ranch Hand
Joined: May 20, 2004
Posts: 132
|
|
Hi all: as you know, in html, if I want the radio button to be the checked when a page loads up, i'd do <input type ="radio" name="r1" checked/> how do i do that in struts? I don't think there is a checked field associated with <html:radio> is there? please let me know... thanks
|
 |
Karl Beowulph
Ranch Hand
Joined: May 31, 2004
Posts: 128
|
|
The way I did it was to pass a value to the .jsp through a bean with a pre-choosen value in there. Following are code snippets Action.java webpage.jsp When the page loads, the radio which matches the value will be highlighted. As far as having it on without a javaBean, I don't know of a way to do that.
|
 |
Mathur Neni
Ranch Hand
Joined: May 10, 2004
Posts: 33
|
|
|
I think, javascript can be one of the solution for selecting a radio button.
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4695
|
|
You don't need any special tricks. Something like this works for prepop: <html:radio property="gender" value="male">Male</html:radio> <html:radio property="gender" value="female">Female</html:radio> ActionForm needs a getter/setter for gender (as usual). If you wanted it to default to Male at the beginning, make "male" the value of String gender in your ActionForm.
|
A good workman is known by his tools.
|
 |
Prakash S.V.S
Greenhorn
Joined: Nov 20, 2003
Posts: 1
|
|
|
Either through javascript or with the help of ActionForm's setter method before loading the page can do this.
|
--<p>Prakash S.V.S
|
 |
 |
|
|
subject: how do i make a radio button to be checked when a page loads up?
|
|
|