Enable/Disable Input based on selection (jQuery)

Posted by Nimbuz on Stack Overflow See other posts from Stack Overflow or by Nimbuz
Published on 2011-01-04T18:35:54Z Indexed on 2011/01/04 18:53 UTC
Read the original article Hit count: 103

Filed under:
|
|
|
<select name="state" class="select" id="state">
    <option value="something">Something</option>
    <option value="other">Other</option>
</select>

<input type="text" name="province" class="text" id="province" />

jQuery

$('#state').change(function () {
    if ($('#state Other:selected').text() == "Other"){
        $('#province').attr('disabled', false);
        alert(1);
    } else {
        alert(2);
    }
});

Doesn't seem to work. I must be doing something wrong.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery