HTML refuses to check radio button by default?
Asked Answered
V

2

15

This looks like a really basic question and I've created dozens of forms, but I just can't see what the problem is here.

I have these two radio buttons:

<input type='radio' class='free atype' value='0' name='dutch' checked='checked'/> Free<br/>
<input type='radio' class='paid atype' value='1' name='dutch' /> Paid

Obviously the first one should be checked by default.

However, when I check the second one and then refresh the page, the second radio remains checked. I know this is wrong behavior, but I can't for the life of me see what I'm doing wrong.

I'm trying this on Firefox.

Varini answered 21/2, 2013 at 18:25 Comment(1)
just a heads up, autocomplete is not a standard attribute: #582744 ... this is just an IE/Firefox thingBield
D
27

This is what's called auto complete, you can try to turn it off by adding the autocomplete="off" property to your inputs

<input type='radio' class='free atype' value='0' name='dutch' checked='checked' autocomplete="off"/> Free<br/>
<input type='radio' class='paid atype' value='1' name='dutch' autocomplete="off"/> Paid

You can also put it on the <form> the elements are in.

Defilade answered 21/2, 2013 at 18:27 Comment(2)
I see. But, since autocomplete seems to be un-standard, I guess I'm better off checking the default button onLoad using Javascript?Varini
@robert #3868799 and w3.org/TR/html-markup/form.htmlDefilade
E
1

Use Autocomplete="Off" as one of the properties in a tag

that will make some sense for that code.

Elly answered 21/2, 2013 at 18:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.