Jquery to change form action

后端 未结 7 1663
孤城傲影
孤城傲影 2020-11-30 23:45

I have two buttons in a form and two different pages have to be called when they are clicked. when button1 is clicked then page1 must be loaded and when button2 is clicked t

7条回答
  •  囚心锁ツ
    2020-12-01 00:16

    To change action value of form dynamically, you can try below code:

    below code is if you are opening some dailog box and inside that dailog box you have form and you want to change the action of it. I used Bootstrap dailog box and on opening of that dailog box I am assigning action value to the form.

    $('#your-dailog-id').on('show.bs.modal', function (event) {
        var link = $(event.relatedTarget);// Link that triggered the modal
        var cURL= link.data('url');// Extract info from data-* attributes
        $("#delUserform").attr("action", cURL);
    });
    

    If you are trying to change the form action on regular page, use below code

    $("#yourElementId").change(function() { 
      var action = ;
      $("#formId").attr("action", action);
    });
    

提交回复
热议问题