SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    USA
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Unchecking checkboxes when "going back"

    I need to uncheck a series of checkboxes when a user uses the back button to return to a page.

    I have determined (at least in IE) that the cached version of the page sets the checkboxes AFTER the page is loaded. The way I have come to this conclusion is by testing several scripts to try to uncheck these boxes.

    When the user goes back, a series of scripts are run. If I test the ".checked" value of the boxes during these scripts, the boxes show "false", but when the page loads, the box will be checked.

    Upon using a button to re-check the values after the page loads, the ".checked" value will now show "true".

    My problem is, I need to automatically uncheck these boxes when a user returns to the page, without using a Body onload event (because the page uses a dynamically generated template and the same form header and body re used on multiple pages).

    Can anyone provide some help on how I may be able to do this?


    Thank You

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Finland
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    Code:
    if (window.addEventListener) {
     window.addEventListener("load", init, false);
    }
    else if (document.all&&window.attachEvent) {
     window.attachEvent("onload", init); 
    }
    init() is your function which resets form elements.

    Opera doesn't trigger onload-events when you use back button so you might be better using onunload to run yor function when user exits the page.

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    USA
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll give it a shot, thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •