I am trying to enable and disable one picklist field based on another picklist field. Here is the piece of code through which i am trying to achieve that
<script>
function Compchange(){
alert('Hello');
document.getElementById('{!$Component.CompLostTo}').disabled = false;
}
</script>
<apex:inputField value="{!closeOppObj.Competitor__c}" onchange="Compchange();"/>
<apex:inputField value="{!closeOppObj.Competitor_Lost_To__c}" id="CompLostTo" />
<script>document.getElementById('{!$Component.CompLostTo}').disabled = true; </script>
i am facing issue with the document.getElementById('{!$Component.CompLostTo}').disabled = false; syntax which is inside the function Compchange(), is it not working as expected. Please suggest how to resolve .. any suggestion will be highly appreciated.