1) Define a java script that takes the action you want as an argument and submits the form with it, e.g.:
<SCRIPT> function refresh(url) { var form = document.forms[0]; form.action = url; form.submit(); } </SCRIPT> 2) Reference the procedure in one of the struts "on*" attributes, e.g.: <html:select property="foo" onchange="refresh('somewhere.do')"/> A couple of caveats: - The <html:submit> tag names the button "submit", so when you attempt to invoke form.submit(), javascript chokes because it thinks you're referencing the button. To solve this, use the "property" attribute on the <html:submit> to call it something else. I use "OK". - Make sure you don't have a property/field in your JSP/Form called "action". You'll run into the same problem as with the submit. - Hardcoding the action strings is a bad idea, because you have to include the name of the webapp, or get tricky with relative URLs. Use <html:rewrite>. However, the JSP compiler won't recognize <html:rewrite> that inside nested quotes, so you couldn't just change the 'somewhere.do' above to "<html:rewrite page='somewhere.do'">. Put the rewrite into a simple string variable and then concatenate to it, or refer to the strings symbolically. For example, the above javascript procedure might be: <script> function refresh(verb) { var form = document.forms[0]; if (verb == "create") { form.action="<html:rewrite page='/widget/create.do'/>"; } else { form.action="<html:rewrite page='/widget/edit.do'/>"; } form.submit(); } </script> and then in the html tag you would put: <html:select property="foo" onchange="refresh('create')"/> HTH sjt > > Hi, > If I have to submit the JSP page when I use struts 1.0.2 with > the form action changing dynamically based on user action, > how do I set the action field using javascript? If anyone has > any suggestions please pass them to me. > > Thanking you in anticipation > _______________________________________________ MVC-Programmers mailing list [EMAIL PROTECTED] http://www.netbean.net/mailman/listinfo/mvc-programmers