Reputation: 137
I am using jade in which I have a checkbox in my code. When user selects a checkbox then value is send as true to the server instead of 1 while for unchecked boxes value is sent as 0. How can I pass value of checkbox as 1 when user checks the checkbox.
input.form-control(type="checkbox", name="compare_form_required", id="compare_form_required", ng-model="program.compareFormRequired")
Upvotes: 0
Views: 908
Reputation: 1
Upvotes: 0
Reputation: 137
I Used ng-true-value="1" that sets the value as 1 on check of a checkbox So I have used it this way :
input.form-control(type="checkbox", name="compare_form_required", id="compare_form_required", ng-model="program.compareFormRequired", ng-true-value="1")
Upvotes: 1
Reputation: 3486
I think there is no way to do so in jade, you can only do something like this afterwards to convert it :
var data = request.body;
if (data.yourCheckbox === 'on') {
data.yourCheckbox = 1;
} else if (data.yourCheckbox) {
data.yourCheckbox = 0;
}
Upvotes: 0