lundi 7 août 2017

Setting a checkbox to unchecked when clicking on drop down

I'd like to be able to uncheck a checkbox if my drop down has been selected using jQuery. I feel like I might almost be there but can't figure out why it isn't working. For example, I click MR but then I change to doctor - MR stays selected.

<script>
$('.multiple-choice').click(function(){
$('input').prop('checked', false);
});
</script>

<fieldset  class="title-box">

<span><input type="radio" name="title" value="Mr" onclick="titlehandler(this)" id="titlemr" th:field="*{title}" /> <label for="titlemr" id="mr-label">Mr</label></span>
<span><input type="radio" name="title" value="Mrs" onclick="titlehandler(this)" id="titlemrs" th:field="*{title}" /> <label for="titlemrs" id="mrs-label">Mrs</label></span>
<span><input type="radio" name="title" value="Miss" onclick="titlehandler(this)" id="titlemiss" th:field="*{title}" /> <label for="titlemiss" id="miss-label">Miss</label></span>
<span><input type="radio" name="title" value="Ms" onclick="titlehandler(this)" id="titlems" th:field="*{title}" /> <label for="titlems" id="ms-label">Ms</label></span>

    <span><label for="dropdown">Other</label>
    <select name="dropdown" id="dropdown" class="multiple-choice"> 


<option value="Dr" name="othertitle1" id="othertitle1">Dr</option>
<option value="Rev">Rev</option>
<option value="Sir">Sir</option>
<option value="Sist">Sist</option></select>
</fieldset>




Aucun commentaire:

Enregistrer un commentaire