0

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.