How To Get The Specific Form Field Value Using Jquery
I have a form
Solution 1:
$("#post_comment").submit(function(event){
var inputValue = $("input[name='type']",this).val();
});
Solution 2:
Try using an id like this:
<form id="post_comment" action="cmt.php" method="post">
<input type="hidden"id='hidden' name="type" value="sub" />
<textarea id="body"></textarea>
</form>
and later:
$("#post_comment").submit(function(event){
var hiddenValue = $("#hidden").val();
});
Solution 3:
<form id="post_comment" action="" method="post">
<inputtype="hidden"class="hidden"name="type"value="sub" /><textareaid="body"></textarea><inputtype="submit"value="submit"class="submit"/>
</form>
$(".submit").click(function(){
var hiddenVal=jQuery("#post_comment .hidden").val();
//alert(hiddenVal);
});
Solution 4:
var form = $(this);
var inputValue = form.find('input[name="type"]').val();
or
var form = $(this);
var inputValue = form.find('input:hidden').val();
Post a Comment for "How To Get The Specific Form Field Value Using Jquery"