• hidden fields and back

    Author
    Topic
    #365818

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #565694

      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 http://www.carr-ferrell.com/pubs/html/faq3.html. 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.

      • #565740

        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.

        • #565746

          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 Must-Visit-From example would capture the event.

          • #565748

            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.

        • #566055

          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:

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

    Viewing 0 reply threads
    Reply To: hidden fields and back

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: