The "if" statement isn't a function, and event handlers like onSubmit
don't require the javascript: prefix. I.e. onsubmit="if (confirm('are
you sure?')==true) { return function2(); } else { return false; }"
also works. I try to include the == true with javascript because js is
known to treat non-boolean values as true when a comparison operator
and value aren't provided, i.e. if (window) is a true condition. It's
probably no big deal, it just makes me a bit leary about not
explicitly declaring the comparison with javascript. I also don't use
the "if (window)" syntax to determine if a variable is defined, I use
"if (typeof window != 'undefined')".
> Robert, the way I have approached this in the past is to
> leverage the fact that the confirm function will return a
> true or false. Since that is the case, simply use it as
> the "test" in an IF function. If the confirm returns true,
> then exectute your second function...else return false.
> Something like this...
> onSubmit="javascript:if(confirm('you sure man?')){ return
> mysecondfunction();} else {return false}}
> Of course I just typed that up adhoc and didn't test it,
> but something along those lines.
> Doug :0)
>>Did you find a solution?
>>
>>I'm suprised it errors. The reason it doesn't work is
>>because you're
>>potentially returning true so checkform never gets called.
>>Try this:
>>
>>onsubmit="if (confirm('Are you sure?')) return
>>checkform(this);"
>>
>>Untested, and I'm not sure what's returned if the user
>>clicks the close(X)
>>button on the dialog box(might be null), so maybe:
>>
>>onsubmit="if ( confirm('Are you sure?') == true ) return
>>checkform(this);"
>>
>>would be better.
>>
>>Adrian
>>
>>-----Original Message-----
>>From: Orlini, Robert [mailto:[EMAIL PROTECTED]
>>Sent: 03 March 2006 20:30
>>To: CF-Talk
>>Subject: SOT: Two functions in OnSubmit
>>
>>
>>Is there any way to include two return functions in an
>>OnSubmit?
>>
>>Here is what I want to do: <form
>>action="getinventory4.cfm" method="POST"
>>onSubmit="return confirm('Are you sure?'); return
>>checkform(this);">
>>
>>Of course it generates an error. But what will work here.
>>
>>Thx in advance
>>
>>Robert O.
>>HWW
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:235734
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54