javascript Submit multiple forms with one button

前端 未结 4 1797
迷失自我
迷失自我 2021-01-02 06:46

In my html I have multiple forms (text inputs, radio buttons, check boxes and select) and one button. I would like to fill all these forms and send values to my php file. Fo

4条回答
  •  鱼传尺愫
    2021-01-02 07:19

    You could try this. If submitting all forms is fine for your page

     $('form').submit();
    

    Function that's in actual use:

    function trySubmitAllForms() {
        if ($('.saveSpinner').is(':visible')) {
            return;
        }
        if ($('form').valid()) {
            $('.saveSpinner').show();
            $('form').submit();
        } else {
            showValidationErrorMessages();
        }
    }
    

提交回复
热议问题