Jquery Get Formaction And Formmethod April 01, 2024 Post a Comment I have the a like this one Solution 1: To get the action or method attributes of a form you can try something like below:$(function() { var action = $("#formid").attr('action'), method = $("#formid").attr('method'); }); CopySolution 2: Hope this helps to get an idea to solve ur problem <form id="popisgolubova_form"> <inputname="pregledaj"type="button"formaction="uredigoluba.php"formmethod="post"formtarget="_self"value="pregledaj"class="button postForm"/> </form> $(document).on('click', '.postForm', function () { $('#popisgolubova_form').attr('action', $(this).attr('formaction')); $('#popisgolubova_form').attr('method', $(this).attr('formmethod')); $('#popisgolubova_form').attr('formtarget', $(this).attr('formtarget')); }); CopySolution 3: So the question is talking about the unfortunately namedhttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction ...which is a way to override https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-actionper clicking a properly set up submit button. The place you want to check this is upon submit - when you're sure things are actually being submitted.Baca JugaJs - Dynamic Href ChangeAdd Video Url, With Live Preview OptionHow To Make The Message Appear Without Typing In The FormThe button you used to submit is stored as :focus - this does not seem to be otherwise stored in the event object at the moment.$('form').on("submit", function(event) { if( $(':focus').is('[formaction]') ) { console.warn($(':focus').attr('formaction')); } if( $(':focus').is('[formtarget]') ) { console.warn($(':focus').attr('formtarget')); } }); CopySolution 4: if( $(':focus').is('[formaction]') ) { console.log($(':focus').attr('formaction')); } CopySolution 5: I had this problem and after searching the web I couldn't find a proper answer. Finally, I realized it's so simple.When you add an event on form.submit you have an event argument that contains e.originalEvent.submitter, just use it as follows: $('form').submit(function(e){ var url = form.attr('action'); if (e.originalEvent.submitter) { var frmAction = $(e.originalEvent.submitter).attr('formaction'); if (frmAction) url = frmAction; } ,..... }); CopyYou can use the samething for the formmethod as well. Share You may like these postsDetecting Individual Unicode Character Support With JavaScriptParse Date String To Date In JavaScriptObserve Sweetalert2 Confirm With Javascript In R ShinyClick Event On Child Div Trigger Action Despite Click Handler Was Set On Parent Using AddEventListener (event Bubbling Was Disabled)) Post a Comment for "Jquery Get Formaction And Formmethod"
Post a Comment for "Jquery Get Formaction And Formmethod"