Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hidden fields and back

    I have a search page that uses expandable/collapsible sections to display the search criteria. If the section is displayed, the user wants to use it in the search. If it is collapsed it is not in the search. I have a hidden field in each section describing whether it is expanded or collapsed. It works very well.

    The problem I have is if you do a search and then click back. All the sections are collapsed (as they are at the beginning) but the hidden fields are still set to the users previous search criteria. They are out of sync.

    Does anyone have a suggestion for how to keep things in sync?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: hidden fields and back

    Seems the code you use to collapse the section will need to also reset the hidden field.

    I had some fun with expanding and collapsing sections. I started with the code used on MS' Technet articles on new security patches, but discovered that it was very IE-centric. The final evolution is posted in a dark corner of our web site <A target="_blank" HREF=http://www.carr-ferrell.com/pubs/html/faq3.html>http://www.carr-ferrell.com/pubs/html/faq3.html</A>. I actually have not gone live with this, as I decided I wanted to make some changes to the arrows. Maybe it will help with cross-browser issues.

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hidden fields and back

    The expanding/collapsing code does set the hidden field. The problem is when the user clicks Back. All the sections are collapsed (default state) but the hidden fields are at their previous values.

  4. #4
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hidden fields and back

    For arguments sake, say you have 3 pages, Index, search, results.
    When the Back button is clicked in 'results' and the 'search' page re-loaded, would it be able to detect what the previous page had been?
    Or would it still assume it had been directed to from the 'Index' page?
    I was just wondering whether some script such as this <A target="_blank" HREF=http://javascript.internet.com/user-details/must-visit-from.html>Must-Visit-From</A> example would capture the event.

  5. #5
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hidden fields and back

    I don't get the impression that the search page is reloaded. perhaps it is. I will try tying some sync code to the load event.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: hidden fields and back

    Oh...going back to the same page we are talking about after submitting it. I missed that...

    It sounds as though "onLoad" or something is running to re-collapse the sections. Yes? If so, you could clear the fields in that function. Maybe you can use the JavaScript reset() function, which emulates a form's reset button, to clear the entire form in one step? Example:

    document.forms[1].reset()

    If there are some fields you need to preserve, you would need to be more specific...

    Alternatively, you probably could force a reload of the page from the server by setting a META tag for no caching. That should guarantee a default condition. Something like this:

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">

    But this would slow re-loading if you have lots of elements.

Posting Permissions

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