Here placed all code http://jsfiddle.net/tUukv/
Below is checkbox created/displayed without jquery. If checkbox value changes, then value in is_checkbox_changed0 changes to 1. All works.
<br>input type='checkbox' without jquery. All works<br>
<table><tr><td>
<input type='checkbox' id='checkbox_to_update0' name='checkbox_to_update0' class='checkbox_to_update_changed0' value = 'true' >
</td></tr></table>
<table><tr><td>
<input type="text" name="is_checkbox_changed0" id="is_checkbox_changed0" style='width:30px;'>
<script>
$(".checkbox_to_update_changed0").change(function(){
document.getElementById('is_checkbox_changed0').value = 1;
});
</script>
</td></tr></table>
But need to display checkbox using jquery
Created such code
<br>But with jquery input type='checkbox' does not work<br>
<script language="javascript" type='text/javascript'>
$(document).ready(function() {
$('#existing_company_error').html("Checkbox <input type='checkbox' id='checkbox_to_update' name='checkbox_to_update' class='checkbox_to_update_changed' value = 'true' ><br>");
});
</script>
<div id="existing_company_error"></div>
<table><tr><td>
<input type="text" name="is_checkbox_changed" id="is_checkbox_changed" size="" style='width:30px;'>
<script>
$(".checkbox_to_update_changed").change(function(){
//$('input[type="checkbox"]').change(function(){
//$(".checkbox_to_update_changed").on("change", function () {
document.getElementById('is_checkbox_changed').value = 1;
});
</script>
</td></tr></table>
If I change checkbox value (either check, or uncheck the checkbox) value in is_checkbox_changed must change to 1. But it does not changes.
Please, advice what need to correct?
Solution Oh, I am stupid. document.getElementById('is_checkbox_changed').value = 1; must be inside $(document).ready(function() {. all works
$(...).is(':checked')is(':checked'). But also need change value if checkbox is unchecked.