Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
74
rated 0 times [  80] [ 6]  / answers: 1 / hits: 19078  / 13 Years ago, wed, july 27, 2011, 12:00:00

How do you enable or disable a select tag after selecting an option from the first select tag in jQuery, but current version is not working.



$(select[name='selectALPHA']).change(function () {
if ($(select[name='selectBRAVO'].attr('enabled') == false {
$(select[name='selectBRAVO']).attr('enabled', 'true');
}
else
{
$(select[name='selectBRAVO']).attr('enabled', 'false');
}
});

More From » jquery

 Answers
239

I'm not so very sure what you are trying to achieve here but I think that this can help you :



$(select[name='select1']).change(function () {
var jSelect2=$(select[name='select2']);

if($(this).val()){
jSelect2.removeAttr('disabled');
}else{
jSelect2.attr('disabled', 'disabled');
}

});


See working example here : JSFiddle


[#90986] Tuesday, July 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaceyr

Total Points: 510
Total Questions: 97
Total Answers: 116

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
kaceyr questions
;