struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brati.sankargh...@tcs.com
Subject Re: "are you sure?"
Date Tue, 23 Mar 2004 09:47:55 GMT
Hi rinkie,

You can use a button instead. call the javascript method on the onclick 
event of the button. donot use submit use a button.

Brati Sankar Ghosh
Tata Consultancy Services
Mailto: brati.sankarghosh@tcs.com
Website: http://www.tcs.com



"rinkeh@home.nl" <rinkeh@home.nl> 
03/23/2004 03:10 PM

Please respond to
"Struts Users Mailing List" <struts-user@jakarta.apache.org>


To
struts-user@jakarta.apache.org
cc

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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


ForwardSourceID:NT00002C0E 

Mime
View raw message