13

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?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Oleg Kubrakov
  • 175
  • 1
  • 1
  • 10

5 Answers5

8

Use

autocomplete="off"

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

Community
  • 1
  • 1
T. Junghans
  • 11,385
  • 7
  • 52
  • 75
6

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.

alex
  • 479,566
  • 201
  • 878
  • 984
  • JohnP made a comment that does for me best, but it should be mentioned that header "Cache-Control: no-cache" also helps. – Oleg Kubrakov Apr 29 '11 at 18:15
1

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.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
1

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

ATJ
  • 309
  • 2
  • 10
-2

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.

Ionut
  • 724
  • 2
  • 9
  • 25