javascript - Create ajax script for multiple form input php html

one text

Solution:

If I'm understanding you correctly, you want every (or multiple) forms on the page to submit at the same time? Here's a simplified JSFiddle showing how that can be done.

Make a button outside of your forms that triggers a submit_all() function. submit_all() collects each form on the page, then runs those through your AJAX function. You can easily modify this to work for only certain forms on the page using classes or data-keys.

However, I would argue that this approach is a bad idea. If you have multiple forms on a page that must be sent together, it would be better to consolidate those forms into a single form. At the very least it will keep information that must be kept together, together and save you some organizational headaches.

In your case you could have one large form and use Javascript to split it into 4 groups, replacing the multiple submits with next buttons to display the next group of inputs.

Personally I would skip the modal approach entirely and show the whole form on it's own page. As a user, it would be nice to know ahead of time that this website wants so much information from me. Filling out a lengthy form only to be shown another form, and another, and another... This will likely lead to frustration.

Source