How can I achieve so using javascript or anything.
My checkbox looks like this
<th>{{ render_field_with_errors(form.polycarbonate_r, value="Polycarbonate", type="checkbox") }}</th>
It's flask WTF form built-in checkbox.
I want to be able to set checkbox value when it's unchecked.
Well the simplest way is to trigger a function when the input state changes, like this:
$('input').on('change', function() {
if ($(this).prop('checked') == false) {
$(this).val('New Value');
}
}
You can also change the value back if it's checked again. Just add an "else" statement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.