Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms & Image Change

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
I have a form with 3 images, when you click the images it updates a hidden field with a status (1,2,3), and changes the image of the clicked icon to highlight it. All this works fine but when they press search and then on the next page they press the back button, the images reset but the hudden field stays the same. This means if they press search again they get the wrong information.

so is there anyway of making javascript do something when the back button is pressed to stop this?!??
 

If you tell your initial page not to be cached, ever, then that may well solve the problem.

I'm not 100% sure about whether or not all browsers will run JS code (for example in the body onload event) when the back button is hit, so you might not be able to successfully use this, depending on your target browser audience.

To tell the initial page not to be cached, put these 3 meta tags in the head section:

Code:
<meta http-equiv="expires" content="Mon, 5 Jan 2004 11:00:00 GMT" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />

Hope this helps,
Dan

 
Thats what I thought. Managed to get around this in the end was to add a check on the submit and then just do a manual check to see which image is cuurently selected and then set the status of the hidden field to the same. pain in the arse way of doing it, but seems to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top