Stop browser from remembering checkbox selections

L

Laser Lips

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.

Thanks
Graham
 
J

Jukka K. Korpela

Laser said:
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.

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" ...>).
 
L

Laser Lips

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.

<script>
var browsers=GetAllBrowsers();
browser.stopTryingToBeClever();
</script>

Oh if only.
Graham
 
J

Jukka K. Korpela

Laser said:
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.

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
http://vista.intersystems.com/csp/docbook/DocBook.UI.Page.cls?KEY=GCSP_tagbased#GCSP_C9141
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')
</script>

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top