Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

handling next and back buttons in javascript

 
mohan kumar r
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dom Lassy
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cookies.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic