here is my html
<input type="checkbox" value="1" name="Visual" id="checkbox1">
<input type="checkbox" value="1" name="Tuberculosis" id="checkbox1">
<input type="checkbox" value="1" name="Skin" id="checkbox1">
<script type="text/javascript">
$('#checkbox-value').text($('#checkbox1').val());
$("#checkbox1").on('change', function() {
if ($(this).is(':checked')) {
$(this).attr('value', 'true');
} else {
$(this).attr('value', 'false');
}
$('#checkbox-value').text($('#checkbox1').val());
});
</script>
this is my views
Visual= request.POST['Visual']
Tuberculosis= request.POST['Tuberculosis']
Skin= request.POST['Skin']
V_insert_data = StudentUserMedicalRecord(
Visual=Visual,
Tuberculosis=Tuberculosis,Skin=Skin
)
V_insert_data.save()
Can you provide an javascipt if the user check the value, the value will become 1 and if the user unchecked the value will become 0.
from django auto check if i save it to database
No comments:
Post a Comment