File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes handling next and back buttons in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "handling next and back buttons in javascript" Watch "handling next and back buttons in javascript" New topic
Author

handling next and back buttons in javascript

mohan kumar r
Ranch Hand

Joined: Jan 19, 2006
Posts: 38
hi,
My requirement is that i have some set of jsps each contain 'next' and 'back' buttons and i need to enter sequence of values. while entering the values i may want to move forward to next page or back to previous page to modify the already entered data.

IS THERE ANY FUNCTIONALITY IN JAVA SCRIPT TO KEEP TRACK OF THE ENTERED VALUES WHILE NAVIGATING BACK AND NEXT SO THAT I CAN MOVE BETWEEN DIFFERENT PAGES WITHOUT SUBMITTING THE VALUES TO SERVER SIDE CODE.


mohan
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
Cookies.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Either you have to post the values to the server and re fill them in or use cookies (as mentioned)

Also refrain from using all capital letters. It implys screaming and is really really hard to read. I am sure we all can see the problem that you are having and do not have to highlight it for us.

Eric
mohan kumar r
Ranch Hand

Joined: Jan 19, 2006
Posts: 38
hi,
i have used cookies to navigate among pages. it is working fine.
Now i have placed links(<a href=...) on top of each jsp so that user can directly go to required page.but before that, in each jsp there are some mandatory fields. if the user click on the link to some other page without entering the values for mandatory fields, i want to display the alert messag. he is allowed to go to other page only when all the mandatory fields are filled up.other wise he has to be in the samepage

for this i have written onclick event for each link on the page
if(document.smtpServiceForm.smtp_server_timeOut.value.length == 0)
{
alert("please enter all the mandatory fields before leaving the page");
document.smtpServiceForm.smtp_param.value="smtp_service";
}
alert("after setting smtp_param to smtp_service");
document.smtpServiceForm.submit();
return;
}
in the above code, smtp_param value decides which page to go nest in the controller servlet.

but it is not working. briefly
my idea is that user can go to other page as specified in href of that link if he filled up all the fields ,other wise he has to be in the same page.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Your code needs to have at least this

onclick="return yourFunction();"


function yourFunction(){

//blah

return false;

}

to keep the links from firing if you are submitting a form wih them.

Eric
 
Consider Paul's rocket mass heater.
 
subject: handling next and back buttons in javascript
 
Similar Threads
Posts Navigation
returning to the previous page with cleared GUI components
Carry values between page submit
request parameters persisting across pages
back button issue