radio buttons

wyrd_fish

Fledgling Freddie
Joined
Dec 27, 2003
Messages
537
is there a way to make radio buttons selected by default?

prhaps a JS or is there a atribute that'll do it???
 

Jonty

Fledgling Freddie
Joined
Dec 22, 2003
Messages
1,411
Hi wyrd_fish

As Padwah says, just add 'checked' (or, technically speaking, checked="checked") to the <input /> tag; e.g.


Code:
<input checked="checked" type="radio" />
Kind Regards
 

wyrd_fish

Fledgling Freddie
Joined
Dec 27, 2003
Messages
537
i thought it was selected, but that didn't work so i asked you lot...
 

Panda On Smack

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,030
Jonty said:
Hi wyrd_fish

As Padwah says, just add 'checked' (or, technically speaking, checked="checked") to the <input /> tag; e.g.


Code:
<input checked="checked" type="radio" />
Kind Regards
I think it just looks at the fact you have the word 'checked' in the tag coz u can put what u like as the value of checked and it still works:

Code:
<input checked="i like men" type="radio" />
so you can just use:

Code:
<input name="MyRadioButton" type="radio" value="1" checked>
 

Jonty

Fledgling Freddie
Joined
Dec 22, 2003
Messages
1,411
Hi Panda

You're of course right that for a long time people just used 'checked' or 'selected' etc, but in the XHTML specification, this is no longer allowed.

W3C XHTML Specification said:
XML does not support attribute minimization. Attribute-value pairs must be written in full. Attribute names such as compact and checked cannot occur in elements without their value being specified.
I know wyrd_wish isn't writing his markup specifically in accordance with XHTML, but still, t doesn't hurt to get into good habits ;) Pages written in XHTML but which don't use the attribute="attribute" probably won't validate.

Anyway, we're probably over labouring the point a bit here. At least it works for wyrd_fish, that's all that matters.

Kind Regards
 

Users who are viewing this thread

Top Bottom