How to post the data of the same form that is in multiple records

1 day ago 3
ARTICLE AD BOX

Yes — it’s absolutely possible.
Right now you're submitting each form individually because your click handler grabs the closest form and only sends that form’s values.

To submit all 5 cloned records at once, you need:

A single global button

Loop through all .myForm forms

Collect all .name and .employid values

Send them as an array in one AJAX request

I suggest you to do something like this:

<form id="mainForm"> <div class="client"> <input type="text" name="name[]"> <input type="text" name="employid[]"> </div> <button type="submit">Submit All</button> </form> <script> $('#mainForm').on('submit', function(e){ e.preventDefault(); $.ajax({ url: 'scripts/test_post.sql.php', type: 'POST', data: $(this).serialize(), success: function(data){ console.log(data); } }); }); </script>

This is cleaner, easier to maintain, and avoids nested forms (which is invalid HTML).

huuyui's user avatar

2 Comments

Thank you! I will try it now :-)

2026-02-24T22:27:56.477Z+00:00

Perfect and clean, thank you very much!

2026-02-24T22:48:38.313Z+00:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Read Entire Article