Forum Moderators: coopster

Message Too Old, No Replies

Mutli SUBMITS in one form is possible

         

indiguy

3:50 am on Sep 21, 2009 (gmt 0)

10+ Year Member



Hi all,

Ive worked out how to use multi submit buttons in one form.
I heard it cant be done, but this is myth.

here is what to do:
In a While loop:
while (blah..){
echo "<td><input type=\"submit\" value=\"Update\" name=\"button1_$id\" ></td>";
echo "<td><input type=\"submit\" value=\"Delete\" name=\"button2_$id\" ></td>";

Note: the _$id //(what ever you want to name that)

$id=$row['id']; //(Im using the PK from the db, use what you want, it so, inciment it.
$id++
}

//plus, use the _$id (eg: "<input type=\"text\" size = 10 name=\"choice_$id\"....>";) at the end of what ever fields u want if updating db rows.. this works very well. Im using on multi rows (from textboxes)
:)
I hope this help someone.

rocknbil

4:31 pm on Sep 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As you've discovered, it's not multiple submit buttons that "can't be done" - it's submitting a form to multiple locations or actions that can't be done (without some Javascript or server side wizardry taking place.) The confusion is demonstrated by your topic title - "Mutli SUBMITS in one form is possible" can be interpreted as multiple form action submissions when you mean multiple submit buttons.

But multiple submit buttons, absolutely, only the submit button pressed will be present in $_POST/$_GET.

However, you still have an issue to work out with what happens when someone presses the enter key. :-)