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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

history.back() or .go() and dynamic form fields

Status
Not open for further replies.

KWade

MIS
Jul 14, 2003
14
US
Hi all,

I am trying to use history.back() to get back to my previous page but the page comes up with empty form fields.

The page I'm trying to get to has a form with several text input fields. I have a selection box that determines the value of another text field.
When a user selects and option from the selection box I pull data from a sql database and dynamically update the value a selection box.
The rest of the text fields are filled in normally by the user.

Why are the fields blank when I go back? Only one field is dynamically set so I kinda figured it'd be blank.

Will I have to reload the field values myself?

Can I tell how the page was loaded without setting a cookie or session variable? ie. something like document.referrer?
Should I use something like the <body onload=&quot;somefunction()&quot;> to check a cookie or session variable?

I'm a little confused on the best way to proceed. Any suggestions will be appreciated. Thanks all.

 
You could try this way.

Code:
From MSDN

saveHistory Behavior

Enables the object to persist data in the browser history.

Example

<objtag STYLE=&quot;behavior:url('#default#saveHistory')&quot;>

Maybe this works, Should work in IE

________
George, M
 
Also you could use something like this taht will work always.

Code:
<form action=&quot;nextstep.asp&quot; method=post>
<input type=text value=&quot;<%Session(&quot;name&quot;)%>&quot; name=&quot;name&quot;>
<input type=text value=&quot;<%Session(&quot;age&quot;)%>&quot; name=&quot;age&quot;>
</form>

nextstep.asp

<%
Session(&quot;name&quot;)=Request(&quot;name&quot;)
Session(&quot;age&quot;)=Request(&quot;age&quot;)
'...
%>


________
George, M
 
Thanks shaddow,

I tried using the saveHistory (found more info on MS ) but I still couldn't get it to work.

I see what you're doing with the second post but how would you go about checking or using the session variables? With a <body onload= >?

Thanks,
 
Dont use nothing just do as normal. No onload events or something... but the form must be submited to server in order to save data in session.

________
George, M
 
shaddow,

Are you saying save all my form variables as session variables? I don't think I can do that. I have some fields that contain large amounts of data and several users using the page. I don't think I want to be storing all that data in session variables.

I thought your example was just storing the page name and age to be used later to determine what page was loaded etc...

 
I dont see any other general solution. Save to database or keep to a session.

________
George, M
 
Another problem with history.back() is that the IE setting Tools, Internet Options, Advanced, Security, Do not save encrypted pages to disk may or may not have been changed by the user. So if you go back into history while in the https:// secure mode then the user might get a &quot;Warning: Page has expired&quot; message that says to refresh the page. It is simpler to go forward than go back.

dbMark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top