Wow, I'm confused. If javascript was disabled, the onSubmit trigger was
ignored, but the button onClick trigger was honored? I'll have to try that
out.

Andreas

-----Ursprungliche Nachricht-----
Von: Dmitrii CRETU [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 23. Marz 2004 11:09
An: Struts Users Mailing List
Betreff: Re[2]: "are you sure?"


we tried to use this (form.onsumbit="return f()") but encountered a problem:
if JavaScript is disabled in browser the submiting goes on without
confirmation dialogue and other stuff done by JS (wich in our case was
more important).

We solved this by setting input.type="button" instead of "submit" and
submitting the form from JacaScript. But this caused another problem
(though less important): now user can not submit form pressing "Enter"
being at text input, he must click the button.


Dima.


Tuesday, March 23, 2004, 11:43:54 AM, you wrote:

JS> Try with this -
JS> <html:form action="/adddate"
JS>       name="dateForm"
JS>       type="nl.rinke.DateForm"
JS>       onsubmit="return areyousure()" >

JS> Should work....

JS> -----Original Message-----
JS> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
JS> Sent: Tuesday, March 23, 2004 3:10 PM
JS> To: [EMAIL PROTECTED]
JS> Subject: "are you sure?"


JS> Hi list,

JS> Still a struts newbie, I try to write an "are you sure" javascript
JS> confirmation box for my submit button.

JS> The question is: how can I prevent the form from being submitted
JS> when the user clicks "no"?

JS> In the Jsp, I put the following code in the head:

JS> <SCRIPT LANGUAGE="javascript">
JS>    function areyousure(){
JS>       var agree = false;
JS>       agree = confirm("are you sure?");
JS>       if(agree){
JS>          ... some code which is not important
JS>       }
JS>       return agree;
JS>    }
JS> </SCRIPT>


JS> And the form tag looks like this:

JS> <html:form action="/adddate"
JS>       name="dateForm"
JS>       type="nl.rinke.DateForm"
JS>       onsubmit="areyousure()" >


JS> Whatever the user clicks, yes or no, the form
JS> gets submitted. I want to stop submitting the
JS> form when the user click "no".

JS> thanks, Rinke


JS> ---------------------------------------------------------------------
JS> To unsubscribe, e-mail: [EMAIL PROTECTED]
JS> For additional commands, e-mail: [EMAIL PROTECTED]


JS> ---------------------------------------------------------------------
JS> To unsubscribe, e-mail: [EMAIL PROTECTED]
JS> For additional commands, e-mail: [EMAIL PROTECTED]



--
Best regards,
 Dmitrii                            mailto:[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]

Reply via email to