+1 vote
in Other by
I have included an additional Submit button within my form which I am going to use like so.

User selects item

User hits "Add another item" Submit button on form.

Form POSTS to itself and reloads the page so user can add another item

Once user has added several items the user hits "Finished" Submit button.

The form posts to another file with all the accumulated items.

I have a uneasy feeling that this might not be achievable with PHP/HTML alone and that I might have to use some Javascript to modify the form action before the form starts to POST data?

Thoughts and ideas?

Thanks

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Give the two submit buttons the same names but different values. You can check the value in your php file.

Example

<form action="something.php" method="post">

<input type="submit" name="submit" value="one">

<input type="submit" name="submit" value="two">

</form>

something.php

switch( $_POST['submit'] ) {

    case 'one':

    case 'two':

}

Related questions

+1 vote
asked Feb 1, 2022 in Other by DavidAnderson
+1 vote
asked Feb 1, 2022 in Other by DavidAnderson
...