F. Vandroy F. Vandroy - 11 months ago 27
jQuery Question

A checkbox like my Select

I have a select element and I need to replace this by the checkbox.

Look at my code:

<select id="civilite" name="civilite" class="form-control" title="Merci de séléctionner une valeur.">
<!-- Choix déroulant -->
<option value="">-</option>
<option value="monsieur">Monsieur</option>
<option value="madame">Madame</option>

And a part of my JS:

civiliteVal = $('#civilite option:selected').val()

Answer Source

I guess you are looking for this https://jsfiddle.net/0rbr16zb/

    var value = $(this).val();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="civilite" value="monsieur" /> Monsieur
<input type="checkbox" name="civilite" value="madame" /> Madame

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download