Sunday, 1 September 2013

jQuery - Submit Form... but also pass submit input name and ID

jQuery - Submit Form... but also pass submit input name and ID

I have the following jQuery code, which automatically submits my form
whenever the user selects a file to upload in the file input field:
jQuery(document).on('change', 'input[type="file"]', function () {
jQuery(this).parents('form').append('<input type="hidden"
name="action" id="action" value="bp_avatar_upload" />').submit();
});
However, I also need to pass along the ID and name of the submit input
with this code. The ID and name for the submit input are both upload, as
seen in the original, non-jQuery code:
<input type="submit" name="upload" id="upload" value="Upload Image" />
Please advise how I may be able to go about this. Very much appreciative
of all help on this!

No comments:

Post a Comment