You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steven Leija <St...@valtech.com> on 2001/06/01 05:46:32 UTC
Using Javascript to cancel submit?
Hello All,
Currently I'm working on a form, but before submit, I have an onSubmit() in my form tag that verifies they want to submit. The problem is that with my confirmation javascript popup, whether the user selects "OK" or "Cancel", the form is still submitted. Is there a way to prevent the form from submitting if the user selects "Cancel"?
Thanks in advance!
Steven
Re: Using Javascript to cancel submit?
Posted by Ted Husted <hu...@apache.org>.
If you want the JavaScript to cancel the submit, you need to return
false somewhere.
Struts can also watch for these in the Action, either using the
isCancel() method, or by looking at the label of the button pressed.
Struts doesn't write the HTML for tables, and could not affect the sizes
of your table rows, except to the extent that the browser adjusts the
row sizes to fit the instant data.
The Struts custom tags (like all others) simply substitute standard HTML
for the custom tags on their way to the browser, and leaves everything
else alone. You can view the source to see what the browser sees. Struts
isn't otherwise involved in how your page renders.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/
Re: Using Javascript to cancel submit?
Posted by Steven Leija <St...@valtech.com>.
Hi Spencer,
I'm checking through my code and unless my return statement is in the wrong place, it didn't fix my problem. Below is my code:
<%
String value = "if (!confirm('Are you sure you want to remove " + TITLE + "?')){return;}; ";
%>
<html:form action="/removeTitle.do" onSubmit="<%=value%>">
<html:hidden property="movieID" value="<%=MOVIEID%>"/>
<html:submit property="ViewTitles">Remove</html:submit>
</html:form>
Also, have you had any problems with struts defining weird sizes on your table rows? My row heights are unusually high, and I haven't set the size.
Thanks for your help!
Steven
----- Original Message -----
From: Spencer Smith
To: struts-user@jakarta.apache.org ; Steven Leija
Sent: Thursday, May 31, 2001 11:06 PM
Subject: Re: Using Javascript to cancel submit?
That is because you do not have a "return" specified on the javascript line.
----- Original Message -----
From: Steven Leija
To: Struts
Sent: Thursday, May 31, 2001 8:46 PM
Subject: Using Javascript to cancel submit?
Hello All,
Currently I'm working on a form, but before submit, I have an onSubmit() in my form tag that verifies they want to submit. The problem is that with my confirmation javascript popup, whether the user selects "OK" or "Cancel", the form is still submitted. Is there a way to prevent the form from submitting if the user selects "Cancel"?
Thanks in advance!
Steven
Re: Using Javascript to cancel submit?
Posted by Spencer Smith <sp...@newdestiny.net>.
That is because you do not have a "return" specified on the javascript line.
----- Original Message -----
From: Steven Leija
To: Struts
Sent: Thursday, May 31, 2001 8:46 PM
Subject: Using Javascript to cancel submit?
Hello All,
Currently I'm working on a form, but before submit, I have an onSubmit() in my form tag that verifies they want to submit. The problem is that with my confirmation javascript popup, whether the user selects "OK" or "Cancel", the form is still submitted. Is there a way to prevent the form from submitting if the user selects "Cancel"?
Thanks in advance!
Steven