> One issue that has caused me a lot of trouble, though, is
> that I often want to be
> able to have buttons on the same form send the user to
> different pages. Of course, a
> form can have only one target URL, so I am stuck there.
> Instead of using <input
> type="submit"> tags for my buttons, I could use links to
> different URLs, but then my
> servlet/controller would never see the values the user has
> entered into the form,
> which is important, since I want these buttons to go to
> "sub-pages" -- similar to
> sub-dialogs in a conventional applications -- whose contents
> and behavior will
> depend on the values in the parent page.
An alternative is to use client-side javascript to set the form's action
property (URL) when the button is clicked and then submit the form. The
O'Reilly DHTML book says the action property is read-write in IE4+ and NN2+.
Instead of type=submit for the button, use type=button and the onclick
handler. Here is an example:
<html>
<head>
<script>
function mySubmit(myForm, submitURL) {
myForm.action = submitURL;
myForm.submit();
}
</script>
</head>
</body>
<form action="default.jsp">
<input type="button" value="one" onclick="mySubmit(this.form, 'one.jsp')" />
<input type="button" value="two" onclick="mySubmit(this.form, 'two.jsp')" />
</form>
</body>
</html>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html