I am very new to JQuery, please consider me as a novice. I have a PHP form where in I have a Radio button. Based on the which radio is selected I would like to disable the select / dropdown. Below is the scenario:
Radio Button: Daily and Misc Select: Deity Name
If the user selects Misc then Select (Deity Name) should be disabled and vice versa.
I have already imported the JQuery on my page.
Header.php
!-- JQuery 1.12.3 JS -->
<script src="../js/jquery-1.12.3.min.js"></script>
HTML Code
<tr>
<td class="col-md-4"><label class="control-label">Pooja Type</label></td>
<td class="col-md-8" align="center">
<label class='radio-inline'><input type='radio' name='poojaType' value='daily' checked>Daily</label>
<label class='radio-inline'><input type='radio' name='poojaType' value='misc'>Misc</label>
</td>
</tr>
<tr>
<td class="col-md-4"><label class="control-label" for="deity">Deity Name</label></td>
<td class="col-md-8"><select class="form-control" name="deityName">
Please advice.
Below is the code for JQuery:
Follow the code:
Assume you have two radio buttons as below:
and one dropdown as below:
you can use below jquery to enable or disable your dropdown by selecting radio buttons:
or you can also use below jquery to enable / disbale your dropdown:
You can just get the
checked value
onchange event
ofradio button
and set it against the attributedisabled
value as below