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

onclick="window.history.back()"

Status
Not open for further replies.

AvaB

Programmer
Jun 23, 2004
16
CA
I have "order.jsp" with a bunch of textboxes where user inputs some
data and "confirm.jsp" which extracts user input and displays it on
screen for verification.

here is my problem: on "confirm.jsp", i have a button called "change"
that should go back to the order.jsp with the user's original input
loaded on the textboxes so that user may edit his original input.
i tried this code and it does not work - it goes back to the
previous page but all the textboxes are empty:

Code:
<input type="image" src="/images/change.jpg" border=0 name="Change" onclick="window.history.back()">

however, if i click on the browser's "back" button (I am using IE), it
works the way i want it to - the user input is loaded in the textboxes.

how do i accomplish this through javascript?

thanks,
AB
 
Store the input values in hidden fields along with displaying them as HTML. The change button then becomes a submit button sending a form with all those hidden values back to your order page (which then reads them into the textboxes).
 
I was playing around with the code and it's weird but apparently, this code:
Code:
<input type="image" src="/images/change.jpg" border=0 name="Change" onclick="window.history.back()">
and this one:
Code:
<A href="javascript:window.history.back()"><IMG src="/images/change.jpg"></A>
have different results. The second one gives me the desired outcome, which is to go back to the previous page where the textboxes still hold the original user input.

Does any one know why?

Thanks Nevermoor for your suggestion.

Regards,
AB
 
Yes.

The reason is because you're setting a hyperlink reference in the first one, therefore reloading the previous page.

if you were to use

<A href="#" onclick="window.history.back();"><IMG src="/images/change.jpg"></A>

Then you shouldn't run into the problem.

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top