Possible Duplicate:
Multiple submit buttons in an HTML form
I wonder whether someone may be able to help me please.
I've put together this form which, as you can see at the bottom of the page, allows a user to add and delete image files associated with the main record.
The problem that I have is that there are multiple buttons that have a 'Submit' action behind them, namely: 'Upload this File', 'Delete Selected Image', 'View Selected Image', and 'Submit' and because of this, immaterial of the button I use, the only action performed is a complete record submission.
Could someone perhaps tell me please how I can make sure that the 'Submit' action behind each button works independently of each other.
Many thanks and kind regards
If you put every button in a separate
<form></form>
it should be fine. Is that possible in your current setup?Assuming you can not do the above:
Form:
JS:
PHP:
If you give your submit buttons a unique
name
, you can tell on the server side which one of them was clicked (resulting in the submission of the form).Try this example:
Just refer this to know about multiple buttons in a single form.
You don't need to use separate form for each button. You can just use different value in the "name" of submit button's. Then on the server you can examine the value of 'form_action'
example :
Put as manu of these buttons as you want. On the server examine the value of $_POST['form_action']