• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Capture the back page event in java script

 
jack burnett
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello..
I have a Jsp page which accepts name, email, address etc and i have a checkbox at the end which says i accept--and theres a link to terms and conditions..
also i have programmed in such a way that the submit button gets enabled only if i check the checkbox(using javascript)..it is disabled otherwise..
the problem is when i check the checkbox and click on terms and conditions and then if i go back to the jsp page(by hitting back) the check box is still checked in the jsp page and the submit button is disabled..i have to uncheck and check the checkbox again to get the submit button working..
is there any way i can resolve this
thanks

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Browser? Firefox will remember form state on back -- other browsers may not.

You can add onload code to explicitly make sure things are in the state that you want.
 
jack burnett
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply..yes it does work for firefox but not for IE or Chrome...
i already have this javascript function which is being called in the definition of checkbox in the jsp page(onclick)..

I also tried the onload but didnt work for me
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this regarding the utility of "it didn't work". That doesn't tell us anything useful.
 
jack burnett
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for reminding about the issue..I will take care of that
basically what i am trying to say is where should i put the onLoad() in the jsp page..
and i was thinking that the definition of the function called by onLoad should be as follows

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's not working? Have you done any debugging?

Also, more people will look at your code if you use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. See this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
jack burnett
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of correcting all my post if you could have put some effort trying to figure out a solution
it would have been better for me and many more people who read this..
I dont think theres anything wrong in my question
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack, Welcome to JavaRanch!

Bear is helping you. But you need to help us by simply putting a bit of effort into your questions and posts. Telling volunteers they need to put effort into helping you isn't the best way to go around these parts. I've edited your posts to include the code tags Bear mentioned. You'll see that this is much easier to read.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't matter where you put onLoad. It loads the same no matter where it is on the page. I generally have it in the HEAD section.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/unsubscribes
 
jack burnett
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply Gregg.. but i have a JSP file and i tried defining onload in many places..
and put an alert in the function so that i know if it can read an onload or not..but i guess not
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the JSP? And please remember to use code tags.
 
jack burnett
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be onload, not onLoad.
 
jack burnett
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No..had tried that earlier
sorry
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jack burnett wrote:No..had tried that earlier
sorry


Yes, because it works fine for me. Maybe you could do what I requested and show me the JSP and not just a fragment. It might even help to show me the post rendered HTML rather than the variabled version. You never know what might be jacked up in your expressions. You should also be using Firebug with Firefox for debugging.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic