Form input - back button

B

Billy Boone

I have a web form that allows the user to enter several pieces of
information. They can then click to see the results (which takes them to a
report form). From this form, if the user clicks the Back button on the
browser - they are returned to the input form and all of their inputs are
what they had entered. However, in the results form I have some links that
when clicked launch new windows (via javascript using window.open).

So I have the link:

<a id='link' href="" onclick="return onBrowse(this.id)">Link</a>

Here is the onBrowse:

function onBrowse(id)
{
window.open("link.asp?id=" + id", "link", "");
return false;
}

If the user clicks on these links then closes the new window. Then the user
clicks the back button from the report form (taking them back to the input
form) - the input form is shown but their selections are lost (they are
returned to their default values). What exactly is going on and how can I
work around this behavior?

Any help would be most appreciated.

BBB
 
J

Jeffrey Silverman

If the user clicks on these links then closes the new window. Then the user
clicks the back button from the report form (taking them back to the input
form) - the input form is shown but their selections are lost (they are
returned to their default values). What exactly is going on and how can I
work around this behavior?

Do you *want* them to still have their selections? Or is a cleared form
what you are lookign for?

Either way, this browser behavior can be quite variable depending on what
browser the user is using and how things like cache and history are set
within that browser. You *cannot* depend on the browser for consistent
behavior.

When I create a form that I want the user's data to not be forgotten when
they submit but there is a mistake or missing required fields or something
like that, I

1) save all the data on the server side in a session
2) send them back to the form using server redirects, but the form is now
filled using the "value=" or "checked" or "selected" properties of the
form fields, based on the saved data.

I use PHP on the server but I'm sure ASP can do the same.

I *never* depend on the browser for consistent behavior. At least on the
server everything is *mine* and I know how it is configured and what it
will do.
 
B

Billy Boone

I want them to still have their selections.

Yeah, I had considered both cookies and session variables. This is an
intranet application so this will be with IE 6.0 only.
 
T

Toby Inkster

As per Jeffrey's suggestion, I'd use frames to get around your problem,
but there was something else I noticed...

Billy said:
<a id='link' href="" onclick="return onBrowse(this.id)">Link</a>

This is a particularly nasty way of opening a new window. Try:

<a href="link.asp?id=" target="mylink"
onclick="return onBrowse(this.href,this.target)">Link</a>

with:

function onBrowse(u,t)
{
window.open(u,t);
return false;
}

Now your link will work when Javascript is disabled too.
 
A

Adrienne

I want them to still have their selections.

Yeah, I had considered both cookies and session variables. This is an
intranet application so this will be with IE 6.0 only.

No reason it couldn't work cross browser, and you really don't have to use
session variables or cookies (which in the real world are not dependable).
You can use the information in the request.querystring collection, or you
can have the form post to itself.

I have an example of this with source code at
http://www.intraproducts.com/beta/requiredform.asp .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top