I’m trying to add a class to a dropdown field on a form based upon which radio button the person selects. Right now the :checked function is only working if the radio button is checked when the page loads. If you select the other radio, the class won’t clear. Here is a link and code:
http://bca.fsa.sunysb.edu/cancel2.php
HTML:
...
<td><label for="action"><strong>Select an Action*</strong></label></td>
<td><input name="action" type="radio" onclick="disableDowngrade(this.checked)" value="Cancel" id="Cancel" /> Cancel a Plan
<span class="h-space"><input name="action" type="radio" onclick="disableCancel(this.checked)" checked="CHECKED" value="Downgrade" id="Downgrade" /> Downgrade Existing Plan</span></td>
</tr>
<tr>
<td><label for="down_amt"><strong>Amount of Downgrade (per Semester)*</strong></label></td>
<td><select name="down_amt" id="down_amt">
<option value="">Select Amount</option>
<option value="-$100">-$100.00</option>
...
JQuery to add class:
if($('#Downgrade').is(':checked')) {
$("#down_amt").addClass("test");
} else if($('#Cancel').is(':checked')) {
$("#down_amt").removeClass("test");
}