This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to persist the values while using history.back  RSS feed

Alok Sharan
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While working with JSP and JAVASCRIPT I came across a unique problem. Let me explain the problem.

Its like I am having a text attribute

input type=text name=myAttribute value=0

and a button like

input type=button name=Submit value=Submit onclic=javascript:myFun()

in the function myFun() in javascript in change the value of attribute myAttribute to 1 as...


followed by submit() call.

This is working fine a new JSP is opening with the data displayed and a BACK button. The click on the Back button is a call of History.back() that takes me back to the previous JSP page.

Now the problem that I am finding is in the global javascript part I put an alert to find the value of the attribute -- myAttribute --. The value that I am getting in alert is 0 and not 1. But the text box is showing the entry as 1 and not 0.

My Findinds: I found that all the attributes whose value has not been changed using any javascript function is showing the correct value at the same place if I see using alert at the global javaScript part.

Pls suggest where I am making mistake.

Bear Bibeault
Author and ninkuma
Posts: 66203
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not use history.back at all. By doing so you are opening yourself up to browser-specific beahavior. You will have more control over what occurs if you wire your "back" button to directly address the target page with whatever parameter values are appropriate.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!