• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Alok Sharan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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...

document.formName.myAttribute.value=1;

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.

Thanks,
Sharan
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!