<%@ taglib uri="/tags/struts-html" prefix="html" %> <html:html locale="true"> <head> <title>JSP page</title> <script type="text/javascript"> function confirmation(){ return confirm("Are you sure to update?"); } </script> </head> <body> <html:form action="/basic" method="POST" > <html:submit onclick="javascript: return confirmation()" value="Update" /> </html:form> </body> </html:html>
This should work. If you have more submit buttons you can use <html:form onsubmit="... instead of <html:submit onclick="... ryan webb-2 wrote: > > Hi everyone! > > I just want to know how to insert javascripts in a struts page? > > here's my version but not working..=( > <html:html locale="true"> > <head> > <title>JSP page</title> > <script type="text/javascript"> > function confirmation(){ > confirm("Are you sure to update?"); > } > </script> > </head> > <body> > <html:form action="update.do" method="POST"> > <html:submit onclick="confirmation()" value="Update"> > </html:form> > </body> > </html:html> > > In my test page works fine, however...(sad part) I am expecting a pop up > window message that confirms if I want to update or not. > but it just proceeds with the action (*.do) > > Any suggestions? > > God bless, > Ryan Webb -- Philippines > > -- View this message in context: http://www.nabble.com/how-to-add-simple-javascript-with-struts--simple-example-please...-tp15999324p16001759.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]