Jquery Get Formaction And Formmethod May 17, 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 JugaConditional Rendering Inside A FunctionIs It Normal For Image Inputs To Be Omitted From The Dom In Document.forms[x].elements?Check Hidden Form Input Has Value On Form SubmitThe 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 postsBackbone.marionette Nested Itemview Either Not Rendering Or Rendering "blank" View/templateEmber Async Computed Property Returns UndefinedMongoosejs/mongodb Search Exact PhraseJavascript Check If Div Overlaps Other Div Post a Comment for "Jquery Get Formaction And Formmethod"
Post a Comment for "Jquery Get Formaction And Formmethod"