Submit form on radio button click - Submit form and perform other actions on radio click

前端 未结 4 1748
心在旅途
心在旅途 2021-02-20 16:34

I have a jQuery question concerning Radio buttons and forms.

I have tabbed content setup with 5 tabs setup with a form in each tab.

Each form consists of 5 radio

相关标签:
4条回答
  • 2021-02-20 16:36

    Try This!!

     $('input[type=radio]').on('change', function() {
    $('input[type=submit]').click();});
    
    0 讨论(0)
  • 2021-02-20 16:42

    The transition from one slide to the next is handled by your submitHandler, so all the radio buttons need to do is submit the form on click, with that in mind:

    $('input[type=radio]').on('change', function() {
        $(this).closest("form").submit();
    });
    

    A couple of notes; firstly I used the attribute selector here, you may want to change that to a class or something more specific for your needs. Secondly, you may also want to include a 'return' method to allow people to change their selections. With this method, if you click once, that's it.

    0 讨论(0)
  • 2021-02-20 16:42

    This worked for me:

    <input name="myRadio" type="radio" value="1" onchange="this.form.submit()"/>
    
    0 讨论(0)
  • 2021-02-20 16:46

    try

     <input type="radio" name="something" onclick="document.getElementById('myForm').submit();"/> 
    

    or

     <input type="radio" name="something" onclick="this.form.submit()">
    

    in jquery try something like

    $('input[type=radio]').click(function() {
        $("form id or class").submit();
    });
    
    0 讨论(0)
提交回复
热议问题