|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Would like to know how to set a default value of a radio button.
I'm able to set it on the click of a button but not while the page is initially loading. Code:
<SCRIPT LANGUAGE="javascript"> document.form.room[1].checked=true; </SCRIPT> <form name="form"> <INPUT TYPE="RADIO" NAME="room" VALUE="Test"> Test <INPUT TYPE="RADIO" NAME="room" VALUE="Cream"> Cream <INPUT TYPE="RADIO" NAME="room" VALUE="Red">Red </form> On loading this page I would like Cream to be checked. How can I do that? document.form.room[1].checked=true; is not working! Thanks |
|
#2
|
|||
|
|||
|
<INPUT TYPE="RADIO" NAME="room" VALUE="Red" CHECKED>Red
![]()
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
|||
|
|||
|
But that would mean that its static, 'Red' would be checked everytime the page is loaded? What if I was to check the radio button depending on some value that was entered in the previous page?
![]() |
|
#4
|
||||
|
||||
|
and what are you using to handle what was entered in the previous page?
|
|
#5
|
|||
|
|||
|
I'm using Java script to interpret a text that was entered in the previous page.
|
|
#6
|
||||
|
||||
|
then use the onLoad even in the body tag to call a javascript function that would set the radio button or your choice checked.
|
|
#7
|
|||
|
|||
|
Got it to work! Thanks so much!
|
|
#8
|
|||
|
|||
|
Quote:
or . . . <input type="radio" name="room" value="red" checked="checked" /> ![]()
__________________
. |
|
#9
|
|||
|
|||
|
Yes, but AFAIK this is XHTML syntax and thus not downward compatible.
|
|
#10
|
|||
|
|||
|
Quote:
Yes, that is XHTML, which I had thought to be backwards compatible with HTML. |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Radio Buttons Default value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|