Stop browser from remembering checkbox selections

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello.  First time posting in alt.html.

Does anyone know of a way to stop a browser from remembering checkbox
selections when you refresh the page? Either by JS Code or HTML.


Re: Stop browser from remembering checkbox selections

Laser Lips wrote:

Quoted text here. Click to load it

You could use the nonstandard attribute autocomplete="off" in the <input>
tag, but it's something undocumented and unreliable; specifically, it does
the job on Firefox 3.5 but not on IE 8, for example. And perhaps mostly by
accident, as a side effect of the way it was implemented in some browsers;
its design goal was to affect autofilling of text input boxes.

Using JavaScript, you could reset the form when the page is loaded (and
refresh is counted as a load):

<body onload="document.getElementById('yourform').reset()">

where 'yourform' is the id of your form (<form id="yourform" ...>).

This implies that when a user accidentally hits Reload after spending half
an our in entering his huge product order that would make you earn a lot, he
wipes away all of the input, unrecoverably, as if he had hit the infamous
destruction button (commonly mislabeled as "Reset" or "Clear").

So if you wish to do something less risky, you might use code that just
clears a particular checkbox, for example, e.g.

<body onload="document.getElementById('foobar').checked = false">

where 'foobar' is the id of your checkbox (<input type="checkbox"
id="foobar" ...>).


Re: Stop browser from remembering checkbox selections

Thanks for your responce Yucca.

I'm dissapointed that the browser providers have not come up with
something stable.

autocomplete="off" does not work for me.

Using JS is probably not an option because I'm using a technology
called CACHE ( not to be confused with the subject of this post )
CACHE is developed by Intersystems.

When using .csp ( as apposed to php or asp ) files, you can 'bind' a
form to a table in the CACHE database and the form auto populates,
however, sometimes the browser is overriding the checkboxes.

   var browsers=GetAllBrowsers();

Oh if only.

Re: Stop browser from remembering checkbox selections

Laser Lips wrote:

Quoted text here. Click to load it

I don't see why that specific server-side technology would prevent the use
of client-side JavaScript. When a browser has got a page, it will be
processed by the browser independently of the server-side code that was run
to generate the page.

Restrictions are possible if the server-side technology munges code that
you, as an author, might write. It can be really annoying. But I don't see
any particular reason why CACHE would do that. Judging from the
documentation snippet
CACHE has tools for making client-side JavaScript programming a bit easier,
not harder.

As usual, it is a good idea to test with a trivial Hello world program, i.e.
with a page containing nothing of interest but

<script type="text/javascript">
alert('Hello world')

in a proper place. If you can do that, you can most probably do a lot more.


Site Timeline