How to check which button have been submitted

Petru Lebada

I have a form, like this:

echo '<table align=center border=1>';
echo '<form method="post">';
echo '<tr>';
echo '<th>Lista Echipamente</th>';
echo '<th>Actiune</th>';
echo '</tr>';
while($row=mysql_fetch_array($sql)){
echo '<tr>';    
echo '<td><input class="search-logi" id="tip" type="text" name="tip" value="'.$row['tip'].'"></td>';
echo '<td><input type=submit name=modifica value=Modifica></td>';
echo '</tr>';
}    
echo '</form>';
echo '</table>';

Because of the loop, this form will have multiple rows. For each input, will be a button. Lets say I want to add a value in the second input, then I will submit it (also the second button, obviously). Here comes the problem, in my code I have just a button, but the user see as many as the loop goes. How can I check which button is submitted?

Kevin

Alternatively, you could utilize <button> tags for this purpose:

echo '<form method="post">'; // form tags are outside to be valid!!!
echo '<table align=center border=1>';
echo '<tr>';
    echo '<th>Lista Echipamente</th>';
    echo '<th>Actiune</th>';
echo '</tr>';

while($row = mysql_fetch_assoc($sql)){
    echo '<tr>';    
        echo '<td><input class="search-logi" type="text" name="tip['.$row['id'].']" value="'.$row['tip'].'"></td>';
        echo '<td><button type="submit" name="modifica" value="'.$row['id'].'">Modifica</button</td>';
    echo '</tr>';
}    

echo '</table>';
echo '</form>';

Then on the processing form:

$modifica = $_POST['modifica']; // shoud return the index num
$tip = $_POST['tip'][$modifica]; // select which textbox

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to check which button have been submitted

From Dev

Check if button has been submitted

From Dev

Check which jRadioButtons have been selected if they have been created in a loop

From Dev

Rails: How to check which form in a view was submitted

From Dev

How to let ngForm know that the form it is nested in have been submitted

From Java

How to check which PHP extensions have been enabled/disabled in Ubuntu Linux 12.04 LTS?

From Dev

How to detect from which button a form is submitted from a loop

From Dev

How to check which <button> was clicked?

From Dev

Identify which button submitted a form

From Dev

How to see which files have not been saved in Android Studio?

From Dev

How to tell which spring-boot Autoconfigurers have been activated?

From Java

How do I show the changes which have been staged?

From Dev

How to determine with JGit which branches have been merged to master?

From Dev

How does django know which migrations have been run?

From Dev

How to tell which modules have been imported in some source code?

From Dev

How to know which files have been deleted by the antivirus

From Dev

Android: How to show a text file which have been downloaded?

From Dev

how to check which radio button is checked in android?

From Dev

Swift - How to check which image is assigned to button

From Dev

(Radiobutton with JSON) how to check which Radiobutton has been selected

From Dev

How I know which button been clicked in class of buttons?

From Dev

How do I detect which radio button has been clicked?

From Dev

How to check if arguments have been correctly passed to Rscript on Windows

From Dev

How can i check if multiple divs have been clicked in JS?

From Dev

How to check if file in ubuntu one cloud have been changed

From Dev

How to check if file in ubuntu one cloud have been changed

From Dev

How to check if arguments have been correctly passed to Rscript on Windows

From Dev

how to check if methods have been called jasmine unit test

From Dev

How to check all desired files have been downloaded in shell script

Related Related

  1. 1

    How to check which button have been submitted

  2. 2

    Check if button has been submitted

  3. 3

    Check which jRadioButtons have been selected if they have been created in a loop

  4. 4

    Rails: How to check which form in a view was submitted

  5. 5

    How to let ngForm know that the form it is nested in have been submitted

  6. 6

    How to check which PHP extensions have been enabled/disabled in Ubuntu Linux 12.04 LTS?

  7. 7

    How to detect from which button a form is submitted from a loop

  8. 8

    How to check which <button> was clicked?

  9. 9

    Identify which button submitted a form

  10. 10

    How to see which files have not been saved in Android Studio?

  11. 11

    How to tell which spring-boot Autoconfigurers have been activated?

  12. 12

    How do I show the changes which have been staged?

  13. 13

    How to determine with JGit which branches have been merged to master?

  14. 14

    How does django know which migrations have been run?

  15. 15

    How to tell which modules have been imported in some source code?

  16. 16

    How to know which files have been deleted by the antivirus

  17. 17

    Android: How to show a text file which have been downloaded?

  18. 18

    how to check which radio button is checked in android?

  19. 19

    Swift - How to check which image is assigned to button

  20. 20

    (Radiobutton with JSON) how to check which Radiobutton has been selected

  21. 21

    How I know which button been clicked in class of buttons?

  22. 22

    How do I detect which radio button has been clicked?

  23. 23

    How to check if arguments have been correctly passed to Rscript on Windows

  24. 24

    How can i check if multiple divs have been clicked in JS?

  25. 25

    How to check if file in ubuntu one cloud have been changed

  26. 26

    How to check if file in ubuntu one cloud have been changed

  27. 27

    How to check if arguments have been correctly passed to Rscript on Windows

  28. 28

    how to check if methods have been called jasmine unit test

  29. 29

    How to check all desired files have been downloaded in shell script

HotTag

Archive