How to I change the action attribute for a html form on submit with JQuery using the jquery form plugin?
-
I am using the following plugin here: jquery.malsup.com/form/ I want to make it so that when the user clicks Submit, it changes the attribute action like: $('$theform').get(0).setAttribute('action', 'theurliwant'); My issue is, I do not know where to put that because the JQuery Form Plugin appears to have its own handlers, and when i stick a click handler on the submit button, it seems to catch the event without going to JQuery Form Plugin's handlers. Where can I stick the code to change the action?
-
Answer:
Take a look at the http://jquery.malsup.com/form/#options-object for your plugin. The answer is there. Under options url: URL to which the form data will be submitted. Default value: value of form's action attribute There is also beforeSubmit Callback function to be invoked before the form is submitted. The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for validating the form data. If the 'beforeSubmit' callback returns false then the form will not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data in array format, the jQuery object for the form, and the Options Object passed into ajaxForm/ajaxSubmit. beforeSubmit: function(arr, $form, options)
Damascusi at Stack Overflow Visit the source
Other answers
Have you tried putting it in here (looking at the API you linked) // attach handler to form's submit event $('#myFormId').submit(function() { // submit the form $(this).ajaxSubmit(); // return false to prevent normal browser submit and page navigation return false; }); though I'm not sure how exactly you are using the, some more code might help out.
RodH257
Related Q & A:
- How do I change HTML content to be a JS variable?Best solution by ehow.com
- How do I change my Yahoo avatar to a girl?Best solution by Yahoo! Answers
- How do i change my yahoo! avatar to a 360?Best solution by Yahoo! Answers
- How do I change my yahoo ID to a different name?Best solution by Yahoo! Answers
- How do I change the home page to a smaller version?Best solution by answers.microsoft.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.