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 JugaOnserverchange Event Not FiringHow To Process Rxjs Stream N Items At A Time And Once An Item Is Done, Autofill Back To N Again?How Can I Replace Everything In Html Body That Matches A Word?The 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 postsSimple Example Of Electron App With Spectron TestHtml5 Audio Player Drag And DropLoad External Js File In Another Js FileTrying To Populate A Drop Down List With Jquery And Ajax Post a Comment for "Jquery Get Formaction And Formmethod"
Post a Comment for "Jquery Get Formaction And Formmethod"