complexi
complexi

Reputation: 427

jquery submit onclick

how do i get an input type="submit" onclick event to fire the commitfunds.valdiate? i can't use a class or id. it must be an onclick event.

here's the code:

<?
foreach ($db->row AS $val){
$("#commitfunds<?=$val['id']?>").validate({
submitHandler: function(form){
    $.post('/pages/aditorials/add_to_cart.php',
$("#commitfunds<?=$val['id']?>").serialize(), function(data) {
        $('#wb_fundsresults<?=$val['id']?>').html(data);
    });
}
});


<form>
<input type="text" name="commit_funds">
<input type="submit" onclick="$(#commitfunds).validate()<?=$val['id']?>;return false;">
</form>
<div id="#wb_fundsresults<?=$val['id']?>"></div>

?>

thanks

Upvotes: 1

Views: 19553

Answers (1)

Dhiraj
Dhiraj

Reputation: 33618

$("input[type=submit]").click(function(){
// do your stuff
});

EDIT: 11/11/14

You can use .submit()

$("form").submit(function(event){
// do your stuff
});

Upvotes: 6

Related Questions