vendredi 4 septembre 2015

Only one checkbox checked and values

I have small problem with checkboxes. Better way to do that is radio button but I must do that with checkboxes.

Here's the code:

$('input.box1').not(this).prop('checked', false).val("N");

DEMO

and it's working because one of checkboxes is checked. But in input value is "true" for this two checkboxes. How Can I change that code to do that when I check checkbox other should have a "false" value.

I try something like this:

$('input.box1').on('change', function() {
        $('input.box1').not(this).prop('checked', false).val("N");
        $('input.box1').this.prop('checked', true).val("T");
        });

but didn't work




Aucun commentaire:

Enregistrer un commentaire