Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-07-2003, 05:24 AM   PM User | #1
loophole
New Coder

 
Join Date: Mar 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
loophole is an unknown quantity at this point
disable onunload if user submits the form only.

I wonder if any one has any idea as i am a little new to j cripts.
The page has a form and this page a onunload script that always run if the user exists this page.
I do not want the page to execute this onunload script if the user submits the form.
I have a function that runs once the user submits this form to verify the data and i am sure i can add a small function to disable the onunload if this script runs.

Thanks,
Hasan
loophole is offline   Reply With Quote
Old 04-07-2003, 07:00 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,032
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Here is what I use - you can adapt it to suit your requirement:-

var submitok = 0;

function submitForm(s) { // called when submit form button pressed
submitok = 1;
return true;
}

function exitform2() {
submitok = 1; // window left via a link to another url so no error message
}

function exitform() { // on window unload, but no error if form was submitted
if (submitok == 0) {
alert ("Has the acknowledgement screen 'Thank you for your order!'\nbeen displayed? If not, you have not clicked on the green\nSUBMIT FORM button and your Order Form has not been sent.");
}
}


<BODY onunload="exitform()">

Links from the page thus:-

<a href="anotherpage.html" onclick="exitform2()">
Philip M is offline   Reply With Quote
Old 04-07-2003, 07:20 AM   PM User | #3
loophole
New Coder

 
Join Date: Mar 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
loophole is an unknown quantity at this point
Thumbs up Thank you

It was that easy....

Thanks a bunch,

Hasan
loophole is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:31 AM.


Advertisement
Log in to turn off these ads.