[Javascript] History.back()

Paul Novitski paul at dandemutande.org
Thu Mar 4 12:06:42 CST 2004


Sudhakar,

It sounds like your problem is that you're going back too far in page history.

Let's say History[0] is your first web page containing a listbox.  At this 
point, the listbox doesn't have any innate value.  The user makes a 
selection and clicks a submit button.  This brings them to:

History[1] is the 2nd web page (or the next iteration of the first page) 
that brings with it the values submitted from the first page.  Here you can 
deal with the submitted form content using a server-side script such as 
CGI, ASP, or PHP.

If you return to your first page, History[0], you'll only see the empty 
listbox.  If you return to your second page, History[1], you'll be at the 
page that knows the values submitted from History[0].

My suggestion is that your 2nd page History[1] should repeat the same 
listbox as your first page.  Instead of returning your user to History[0], 
return them to History[1].

You can use a server-side script to build your 2nd page History[1] to 
contain a listbox populated with the same values as the listbox on the 
originating page.  Here's an ASP example:
_____________________________________

dim aOptions
aOptions = Array("Apple Banana Carrot")

response.write "<select name='listbox'>"

for i = 0 to UBound(aOptions)
         response.write "<option"
                 if request.form("listbox") = aOptions(i) _
                 then response.write " selected"
         response.write ">" & aOptions(i)
next

response.write "</select>"
_____________________________________

History pages [0] & [1] can be the same page, with the form submitting the 
page to itself.  The above listbox will initially be valueless but will 
reflect the value selected after submission.

Paul


At 12:30 AM 3/4/2004, you wrote:
>Hi all,
>         I select some values in a listbox and go to verify page.
>         I using history.back() to navigate back to the page containing 
> list boxes. The text field in the page holds the previous values but the 
> list boxes are reset to the default values....
>         Please suggest anyway where i can go back to the previous page 
> with selected values
>"intact"
>
>Thanks in advance,
>Sudhakar





More information about the Javascript mailing list