Untitled

Vælg køn - print hvilket valg man tog i select. Mand / Kvinde med check flueben. Korrekt lavet eller ?
mail@pastecode.io avatar
unknown
html
2 years ago
890 B
124
Indexable
Never
<div class="form-group text-center">



<div class="btn-group btn-group-toggle" data-toggle="buttons">
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option1" autocomplete="off" checked class="gender" value="1"> Mand<span id="choiceGender1"></span>
  </label>
  <label class="btn btn-danger">
    <input type="radio" name="options" id="option2" autocomplete="off" class="gender" value="2"> Kvinde<span id="choiceGender2"></span>
  </label>
</div>

</div>
<script>
$( ".gender" ).change(function() {
if($(this).attr('value') == 1) {
var value = document.getElementById("option1").value;
$( "#choiceGender1" ).html(" <i class='fa-solid fa-check'></i>");
$( "#choiceGender2" ).html("");
} else {
var value = document.getElementById("option2").value;
$( "#choiceGender2" ).html(" <i class='fa-solid fa-check'></i>");
$( "#choiceGender1" ).html("");
}
});
</script>