javascript - I have several select, how do I select only one option to true and set the others to false? -
how select 1 option true , set others false, regardless of select user choose real option?
note: user can not choose 2 options true.
$(function() { $('select[name="verdadeira[]"]').change(function() { $('select[name="verdadeira[]"]').each(function() { if($(this).val() == 'v'){ $(this).val('v'); } }); }); }); <select class="form-control v" name="verdadeira[]" style="width: 120px; height: 37px; float: left;" > <option value="f" selected="selected"> falsa</option> <option value="v">verdadeira</option> </select> <select class="form-control v" name="verdadeira[]" style="width: 120px; height: 37px; float: left;" > <option value="f" selected="selected"> falsa</option> <option value="v">verdadeira</option> </select> <select class="form-control v" name="verdadeira[]" style="width: 120px; height: 37px; float: left;" > <option value="f" selected="selected"> falsa</option> <option value="v">verdadeira</option> </select>
Comments
Post a Comment