Friday, October 5, 2012

Multiple actions/buttons form in HTML

create a form like this:

form name="myform" onsubmit="return onsubmitform();" method="post"

The onsubmitform is something like:

<script type="text/javascript">
function onsubmitform() {
 if (document.pressed == "Purge Messages Selected") {
  document.myform.action = "purgemessages.jsp";
 else {
  alert("unknown action");
 return true;

each "active" control should be like :
<input type="submit" name="operation" onclick = "document.pressed=this.value" value="Purge Messages Selected" title="purgeallmsg" />

the above is a button, but the onclick can apply to anything (radio button...).... actually any event can trigger the submission.

No comments: