sveti petar
sveti petar

Reputation: 3787

HTML refuses to check radio button by default?

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.

Upvotes: 15

Views: 28965

Answers (2)

Musa
Musa

Reputation: 97672

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.

Upvotes: 27

satheesh kumar
satheesh kumar

Reputation: 139

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

that will make some sense for that code.

Upvotes: 1

Related Questions