Hi James:
But what if you have multiple html:submit's in your jsp...
And supposing only 1 of those submit button's need to have this javascript
confirm() popup. How does the "onSubmit()" at the form level know which
submit button-property was set? It would need to do an if statement and
only popup the question if a certain submit was set:
For example:
Suppose I have the following in my html form:
<html:form onSubmit="checkDeleteConfirmation()">
....
<table ...>
<tr>
<td ID="small"><html:submit property="add" value="Add" /><td>
<td ID="small"><html:submit property="update" value="Update" /><td>
<td ID="small"><html:submit property="delete" value="Delete" /><td>
...
</table>
</html:form>
Supposing I only want to pop the question when they hit delete:
<script language="JavaScript">
function checkDeleteConfirmation() {
//
// How can I determine if they clicked on the "delete" button
since onSubmit()
// gets called for every single submit type button?
}
</script>
thanks,
Theron
James
Mitchell To: Struts Users Mailing List
<jmitchtx@tel <[EMAIL PROTECTED]>
ocity.com> cc:
Subject: RE: I'm stuck on the html:submit
04/02/02
08:52 PM
Please
respond to
Struts Users
Mailing List
Ok. I was going to make another suggestion based on what you posted
earlier.
You don't actually need any javascript in your <html:submit tag.
The onSubmit action is handled by the <html:form onSubmit="return
callMyFunction()"
Anyway, you could have tested your function call by substituting <html:form
action="/whatever" onSubmit="return true">
then change it to "false" and test again
if that passes, then put return true on the first line of your javascript
function.
Working example:
------------------------------------------------------
<!-- pieces taken from the struts example -->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:form action="/saveRegistration" onsubmit="return doMeFirst('what you
need')">
<table border="0" width="100%">
<tr>
<th align="right">
<bean:message key="prompt.fullName"/>
</th>
<td align="left">
<html:text property="fullName" size="50"/>
</td>
</tr>
</table>
<html:submit value="Submit"/>
</html:form>
<SCRIPT LANGUAGE="javascript">
<!--
function doMeFirst( param ){
if (param == "what I was expecting") {
return true;
}else{
return false;
}
}
//-->
</SCRIPT>
JM
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 02, 2002 10:58 PM
> To: Struts Users Mailing List
> Cc: [EMAIL PROTECTED]
> Subject: RE: I'm stuck on the html:submit
>
>
>
> I apologize James, I ended up doing it a totally different way (without
> using html:button) which seems to work now.... I did not save the
prior
> way that I was having problems with :-(
>
> theron
>
>
>
>
> James
>
> Mitchell To: Struts Users
> Mailing List
> <jmitchtx@tel
> <[EMAIL PROTECTED]>
> ocity.com> cc:
>
> Subject: RE: I'm
> stuck on the html:submit
> 04/02/02
>
> 07:26 PM
>
> Please
>
> respond to
>
> Struts Users
>
> Mailing List
>
>
>
>
>
>
>
>
> Could you post your entire jsp code to have a better look?
>
> JM
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, April 02, 2002 8:51 PM
> > To: Struts Users Mailing List
> > Subject: I'm stuck on the html:submit
> >
> >
> >
> > I know with the html:form you have the "onSubmit()" javascript
> handler in
> > which the following will work:
> >
> > <script language="JavaScript">
> > function unlinkConfirmation() {
> > if (confirm("Remove employee link?"))
> > return true;
> > else
> > return false;
> > }
> > </script>
> >
> > <html:form onSubmit="return unlinkConfirmation()" ... >
> >
> > But when using the plain ol' html:submit, I cannot seem to
> get a return
> > of "true" from the unlinkConfirmation() to cause the form to be
> submitted.
> >
> > I have:
> > <td ID="small"><html:submit property="unlinkEmployee" onmouseup
> > ="return unlinkConfirmation()">Link</html:submit></td>
> >
> > My form never gets submitted regardless as to whether or not I
> answer Yes
> > or No on the confirm message.
> >
> > Can someone help tell me what I am doing wrong?
> >
> > thanks,
> > Theron
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail: <
> mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <
> mailto:[EMAIL PROTECTED]>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>