I have a php form and am using jquery to edit the name attribute before the form is submitted. I am passing a variable in the class attribute and then adding that to the name attribute so I can use it again when the form is processed. I'm using the following code to accomplish this. The change to the name attribute is triggered when the submit button is pushed. Once the function is completed I want the form to be submitted without the user needing to take any other action. I've tried a number of different ways and have not been able to get the form to submit. Any suggestions?
var eachClass = $(this).attr('class');
var eachName = $(this).attr('name');
Just remove the "event.preventDefault()" line. Your function will be executed before the submit takes place, and you want the submission to happen anyway, so it's unnecessary.
Why didn't the trigger work?
I think it's because you were trying to access an element that no longer existed. You looped through each <input> element and added an underscore and that element's classes to its name. And your submit button is an <input> element, so even if it didn't have any classes, its name was still changed to "csvsubmit_".
Thanks, removing the event.preventDefault() worked.
This topic is now closed. New replies are no longer allowed.