user893664
user893664

Reputation: 319

How to create a button in a jsp page, that submits all forms on that page to their resp. form action

I have a JSP web page where multiple forms are shown at a time. I want to create one button that submits all forms to their respective actions. Can this be done? How to implement this? All the forms belong to different 3rd party sites.

Upvotes: 1

Views: 7540

Answers (1)

pap
pap

Reputation: 27614

Ajax post. For example, use jQuery and the jQuery Form plugin.

Then something like this to submit all forms with a button click

<input type="button" value="Submit all" id="submitAll">

<script type="text/javascript">
    $(document).ready(function() {
        $('#submitAll').click(function() {
            $('form').ajaxSubmit({
                success: function(responseText, statusText, xhr, $form) {
                    alert('form submitted, return status:' + statusText);
                }
            });
        });
    });
</script>

Upvotes: 2

Related Questions