Adding a Click event to a submit button and then submitting the form

Posted by Abs on Stack Overflow See other posts from Stack Overflow or by Abs
Published on 2010-05-21T22:05:04Z Indexed on 2010/05/21 22:10 UTC
Read the original article Hit count: 143

Filed under:
|

Hello all,

I have a form with a submit button. I have attached a click event to that submit button using JQuery. Once I did this my form wasn't submitting, I thought this was because of the event I added- if I remove that click event it submits the form successfully.

I have tried giving my form an id and calling the submit function but this was not successful either. What can I do?

$('#submit_gen').click(function() {

  $('#genbtn').html('<img src="images/ajax-loader.gif" alt="loading" />');

  $('#action_form').submit(); 

});

The HTML:

<form id="action_form" action="generate.php" method="post" enctype="multipart/form-data"> 

<input id="file_upload" type="file" name="upload" onchange="file_select();"/>

<input type="text" id="overlay_input">

<div id="genbtn" class="genbtn">
<input id="submit_gen" type="submit" value="Upload">
</div>

</form>

Thanks all

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript