Michael Angelo Jopia Michael Angelo Jopia - 2 years ago 115
HTML Question

Dropdown not disable when radio button is clicked

It's supposed to be working but unfortunately it isn't. I don't know what is wrong with my code. When I try in jsfiddle , it's working but in my Notepad++ it doesn't works. I can't figure out what's wrong with this.

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript">

$('input:radio[name="senior"]').change(function() {
if ($(this).val()=='Yes') {
} else

$('#seniordis').removeAttr('disabled', true);


Senior :

<input name="senior" type="radio" id="Yes" value="Yes" />Yes
<input name="senior" type="radio" id="No" value="No" selected="selected" />No<br />
<select name="seniordis" id="select">
<option value="100" >100% discount</option>
<option value="50">50% discount</option>
<option value="10">10% discount</option>

Answer Source

Your problem is, senoirdis is name not a id. Your id is select.

    $('input:radio[name="senior"]').change(function() {
        if ($(this).val()=='Yes') {

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