Oleg Kubrakov
Oleg Kubrakov

Reputation: 175

How to explicitly set checkbox unchecked

I have a xhtml page with transitional doctype having a checkbox that I want to be unchecked after loading. No JavaScript! In Firefox 3.5 (for instance, there may be other browsers) user can check input, than reload page and get input checked. How can I overcome this behaviour?

Upvotes: 13

Views: 53227

Answers (5)

ATJ
ATJ

Reputation: 325

To explicitly set the checkbox to unchecked, the following worked for me: <input type="checkbox" unchecked>

Upvotes: 1

Ionut
Ionut

Reputation: 839

Try to put in your code this:

<p><label><input id="test" type="checkbox"></input>Test checkbox</label></p>

It will be unchecked when the page starts or refreshes.

Upvotes: -2

T. Junghans
T. Junghans

Reputation: 11683

Use

autocomplete="off"

Also have a look at Why does the checkbox stay checked when reloading the page?

Upvotes: 8

alex
alex

Reputation: 490153

You can't do much to change a document's state with HTML alone. All you can do is set checked="checked" or not.

You need either JavaScript or a server side language to determine whether that attribute should be set or not.

Upvotes: 6

Pekka
Pekka

Reputation: 449395

You can't, not without JavaScript. This is Firefox specific behaviour which would occur even if you could explicitly force an "unchecked" state (which you can't, because the absence of checked already means that.)

The only non-Javascript way that I know of is to rename the form element on server-side on every request so FF has no chance of storing the value.

Upvotes: 1

Related Questions