Robert,

Nice and clean, I assume that you pair this function up with an ===> onClick="check_exit('http://www.google.com');" type statement within the "<a href" statement correct?

- stephen


On May 30, 2007, at 7:38 PM, Robert Garcia wrote:

Use a JS conditional alert, called confirm()

<script language="JavaScript">
<!--
function check_exit(url){
input_box=confirm("You have made changes to the form, are you sure you want to exit this page? Click continue to exit to your link, or cancel to finish the form.");
        if (input_box==true){
                // Output when OK is clicked
                self.location=url;
        } else {
                // Output when Cancel is clicked or just do nothing.
        }
}
//-->
</script>

The only I didn't do here, is the part where you check if the form is changed. You can do that by setting a global variable that is changed to true when any field changes.


--

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[EMAIL PROTECTED] - [EMAIL PROTECTED]
http://bighead.net/ - http://eventpix.com/

On May 30, 2007, at 2:13 PM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:

Hi all,

My question regards the best way to control the exit from a form that contains both <input>s and links. I would like to be able to warn the user, when he activates a link, that changes were made and the submit button has not been clicked so that he can take the appropriate decision.

I have 2 solutions to this issue:
1- make links to act like submit; but this implicitly saves info that he might not want to; 2- use a JavaScript variable that memorizes any change in <input>s and can be evaluated when the user clicks a link; this means that every entry has to be wired-up for the event.

I can live with (2), but I thought maybe there is a better/simpler solution, a global "this page has been modified" attribute that can be checked before switching context and I do not have to wire every input.

Any thoughts on this subject would be highly appreciated.

Many thanks,
Mike B.

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.3/824 - Release Date: 5/29/2007 13:01

_____________________________________________________________________ ___
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

______________________________________________________________________ __
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf


________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to