multiple submit buttons

Hi

I have a form in which I have 2 buttons

save and new - saves form and returns back to this page

save and close - saves form and returns to the main menu

This means here I have 2 buttons .. one action .. and 2 forwards .

How do I implement this any idea ?

Thanks

[309 byte] By [ns123a] at [2007-10-2 16:48:37]
# 1
Hi, Plz give a clear view that you are using.i think that you are using 2 buttons in a single page or 3 buttons.send it i will reply you.
hgjgha at 2007-7-13 17:59:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi .. I have a page with 2 submit buttons .

I have one "save" action

Save & New button-> goes to the save action and on success it comes back to the same form

Save & Close button -> goes to the save action and on success it goes to the mainmenu .

So I need some way in which my action class can check which button was pressed and appropriately forward to the same page or main menu page

ns123a at 2007-7-13 17:59:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
HI,whether you are using any servlets or any java file for redirecting. what's the use of new and close button functionality?
hgjgha at 2007-7-13 17:59:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Have a hidden field whose name is say buttonPressed.

Have a javascript function that submits your form.

Call this function on the click of the 2 buttons.

Pass the form object and an identifier for the button along when this function is called.

<script>

function doSubmit (f, whichButton){

f.buttonPressed.value = whichButton;

f.submit();

return false;

}

</script>

<form action = "url">

<input type = "hidden" name = "buttonPressed">

//other fields

<input type = "submit" value = "Save And New" onClick = "doSubmit(this.form, 'new')>

<input type = "submit" value = "Save And Close" onClick = "doSubmit(this.form, 'close')>

</form>

The value of request.getParameter("buttonPressed") on the server will tell you which button was clicked.

ram.>

Madathil_Prasada at 2007-7-13 17:59:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

A slight modification.

<input type = "submit" value = "Save And New" onClick = "return doSubmit(this.form, 'new')">

<input type = "submit" value = "Save And Close" onClick = "return doSubmit(this.form, 'close')">

ram.

Madathil_Prasada at 2007-7-13 17:59:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...