*
The moose likes HTML, CSS and JavaScript and the fly likes Capture the back page event in java script 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 "Capture the back page event in java script " Watch "Capture the back page event in java script " New topic
Author

Capture the back page event in java script

jack burnett
Greenhorn

Joined: Dec 29, 2009
Posts: 7
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

Joined: Jan 10, 2002
Posts: 60822
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jack burnett
Greenhorn

Joined: Dec 29, 2009
Posts: 7
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

Joined: Jan 10, 2002
Posts: 60822
    
  65

Please read this regarding the utility of "it didn't work". That doesn't tell us anything useful.
jack burnett
Greenhorn

Joined: Dec 29, 2009
Posts: 7
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

Joined: Jan 10, 2002
Posts: 60822
    
  65

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

Joined: Dec 29, 2009
Posts: 7
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Jan 10, 2002
Posts: 60822
    
  65

/unsubscribes
jack burnett
Greenhorn

Joined: Dec 29, 2009
Posts: 7
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

Can you show us the JSP? And please remember to use code tags.
jack burnett
Greenhorn

Joined: Dec 29, 2009
Posts: 7
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

It should be onload, not onLoad.
jack burnett
Greenhorn

Joined: Dec 29, 2009
Posts: 7
No..had tried that earlier
sorry
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Capture the back page event in java script
 
Similar Threads
JSP : 508 Compliant
javascript..enabling and disabling a submit button
JSP and Javascript
maintin checkbox stauts during paginatin(dispalytag)
maintain checkbox status while doing pagination