php - Capturing values from outside a Form with Javascript -
full page @ http://f14.co/auto-search/reno
i have following checkbox set outside form:
<div class='span5' style='margin-left:0px !important;'> <label for='model0'> <input type="checkbox" name="model0x" id="model0x" value="accord" style='margin-top:-5px !important;'> accord</label> </div>
i have javascript between checkbox , form:
<script> if($("#model0x").is(':checked')){ $("#model0_is_checked").val($("#model0x").val()); }else{ $("#model0_is_checked").val("not checked"); } </script>
finally, have hidden input call value inside form when item checked or not:
<form method="post" class="form-horizontal" id="final_form" action="send_mail.php"> <input type="hidden" id="model0_is_checked" name="model0_is_checked"> more form stuff , submit button </form>
no matter i'm getting no value in send_mail.php ....what doing wrong?
bind function form submit.
<script> $('#final_form').on('submit',function(){ if($("#model0x").is(':checked')){ $("#model0_is_checked").val($("#model0x").val()); } else { $("#model0_is_checked").val("not checked");} }); </script>
jsfiddle example http://jsfiddle.net/kzrlp/
Comments
Post a Comment