Simplest thing to do here is make the method handle the submit for you.
Replace the submit button with :
<html:button property="dummySubmit"
onclick="areyousure();">Submit</html:button>
Then change the javascript to use
...if (agree){formname.submit();}
Good Luck,
Colm
-----Original Message-----
From: Janarthan Sathiamurthy [mailto:[EMAIL PROTECTED]
Sent: 23 March 2004 09:44
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: RE: "are you sure?"
Try with this -
<html:form action="/adddate"
name="dateForm"
type="nl.rinke.DateForm"
onsubmit="return areyousure()" >
Should work....
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 23, 2004 3:10 PM
To: [EMAIL PROTECTED]
Subject: "are you sure?"
Hi list,
Still a struts newbie, I try to write an "are you sure" javascript
confirmation box for my submit button.
The question is: how can I prevent the form from being submitted
when the user clicks "no"?
In the Jsp, I put the following code in the head:
<SCRIPT LANGUAGE="javascript">
function areyousure(){
var agree = false;
agree = confirm("are you sure?");
if(agree){
... some code which is not important
}
return agree;
}
</SCRIPT>
And the form tag looks like this:
<html:form action="/adddate"
name="dateForm"
type="nl.rinke.DateForm"
onsubmit="areyousure()" >
Whatever the user clicks, yes or no, the form
gets submitted. I want to stop submitting the
form when the user click "no".
thanks, Rinke
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]