How to be in this situation? There are 3 submit buttons (move, delete, search). How to track separately when delete is pressed when move and so on. At the moment, it turns out if I drive something into the search and press the enter in POST to get the values of all 3 buttons.
- Why do they all submit? Or why are they all in the same form? - Alexey Ten
- I did not think about it if you honestly. That is, the search can be wrapped in one form, the rest in another? - quaresma89
- Sure you may. And, apparently, even necessary. - Alexey Ten
- P-design. The most important stage of development. - Vasily Barbashev
|
1 answer
Give all buttons the same name ( name ), but different values ( value ). The value associated with the pressed button will be transmitted to the server.
Example:
HTML (client side):
<input type="submit" name="action" value="Move To" /> <input type="submit" name="action" value="Delete" />PHP (server side):
if ($_POST['action'] == 'Move To') { // ... } else if ($_POST['action'] == 'Delete') { // ... } else { // Защита от (вероятно злонамеренно) некорректного значения }
- php is not listed in the question - Igor
- How then is the form processed? Javascript? Then you can assign your
onclickhandler to each button. - ߊߚߤߘ
|
