F.Joodaki F.Joodaki - 3 months ago 17
HTML Question

how to submit a form without input submit

I would like to submit a form without a input submit.

I want to submit this form after click on an

img
tag .

I have a form like this:

<form name="form-form" action="http://localhost/php/enteqal-ax.php" method="post" id="submit_form ">
<input type="hidden" id="value1" name="value_php">
</form>


I have an image like this:

<img id="img" width="100px" height="100px" src="http://www.shadyab.com/assests/images/upload/thumb_open-menu-roko-restaurant_(17)3.jpg">


my java script code :

$('#img').click(function() {
var img_src = $('#img').attr('src');

$('#value1').val(img_src);
$('#submit_form').submit(); // not works at all


});

Answer

Please remove the space present at the end of your form id like:

id="submit_form "

change it to

id="submit_form"
Comments