Hi Dima, list,
[Dima wrote] 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. [end of quote] Personally, I would not consider this as a problem. I noticed that quite some users mistakenly press the Enter key, without yet wanting to submit. So I tried your sollution, and it works fine, making the html:submit into a html:button, which calls a javascript function which calls submit. But since the official submit button has now disappeared, pressing enter results in the next button being processed by default, which is the cancel button (which I would not want either). So by implementing this, I cannot use <<html:cancel> anymore. What would be the best sollution for that? I thought of putting a javascript function "goCancel()" under a <<html:button>, which does this: document.myform.action="somenextpage.do"; document.myform.submit(); However I wonder if there are any smarter sollutions. Is there for example some way to set IsCancelled to true from the jsp, so I can just use the same actions as i do with submit? thanks, Rinke 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: struts-user- [EMAIL PROTECTED] JS> For additional commands, e-mail: [EMAIL PROTECTED] JS> --------------------------------------------------------------------- JS> To unsubscribe, e-mail: struts-user- [EMAIL PROTECTED] JS> For additional commands, e-mail: [EMAIL PROTECTED] -- Best regards, Dmitrii mailto:[EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user- [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <color><param>0100,0100,0100</param>------- End of forwarded message ------- ------- End of forwarded message ------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]