I have 2 select boxes, “#Country” and “#StateAbbreviation” if a user selects a country other than USA – .val=”USA” in the #Country select box, I need to change the value in “#StateAbbreviation” to OTHER/INTL. – val=”IT” and make it disabled.
Why doesn’t this work?
$("#Country").change(function() {
if($(this).val() != 'USA') {
$("#StateAbbreviation").val() == 'IT'.attr("disbled", true);
}
});
Kane Leins
You need to change it a bit, like this:
When setting a value, the call is
.val(newValue), otherwise you’re trying to set a function to a string, and call a function that doesn’t exist on a string…causing a few errors.This also resets the
#StateAbbreviation<select>and re-enables if it is “USA”.