Changing a select option with jquery
I'm changing a select element from another select element with jquery, the code works perfectly once but doesn't after that.
Basically it's a simple, change a select option, if one particular value is selected change a different select option (to select one particular option and disable that field).
From the second time onwards the field still disables, but it doesn't select the desired option.
What am I missing here?
- $("#<portlet:namespace />orderType").change(function() {
- var orderVar = $( "#<portlet:namespace />orderType" ).val();
- if (orderVar == 'Value Based'){
- $("#<portlet:namespace />productType option[value='service']").attr("selected", true);
- $("#<portlet:namespace />productType").attr("disabled", true);
- }
- else {
- $("#<portlet:namespace />productType").attr("disabled", false);
- }
- })