php - Calling Value from Outside a Form when Checkbox is Checked -


i've got this...hopefully can lock up.

this first part checkbox outside form:

<div class='span5' style='margin-left:0px !important;'>                         <label for='model0'>                             <input type="checkbox" name="model0" id="model0" value="test" style='margin-top:-5px !important;'> test</label>                     </div>  . 

this script sending value of of model0 (when checked) send_mail.php in form area.

$("#final_form").submit(function () {      $("#model0_is_checked").val($("#model0").is(':checked'));     return test;     }); 

and form area:

<form method="post" class="form-horizontal" id="final_form" action="send_mail.php">         <input type="hidden" id="model0_is_checked" name="model0_is_checked" value="test" />    more form stuff , submit button     </form> 

when call model0_is_checked, true rather "test" i'm trying call...anyone know why?

.is(':checked') returns true or false whether checkbox checked. not return value. like:

//if checked if($("#model0").is(':checked')){     //set value     $("#model0_is_checked").val($("#model0").val()); //not checked } else {     //set other default value     $("#model0_is_checked").val("not checked"); } 

however, if include checkbox in form, value of checkbox on submit , no value if not checked. on submit, in php, $_post['model0'] equal test if checked , $_post['model0'] not set if not checked. can $model0 = isset($_post['model0'])?$_post['model0']:null; value without error.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -