+ Start a Discussion
DeepVDeepV 

Onclick, how to get the inputfield value ?

Onclick of the button on vf page. How can I get the input field lookup value.
I have a lookup value A,B,C. based on the condition, say lookup == "A" then I want to enable or disable the inputfield.
Can I achieve this from javascript?
TIA
Best Answer chosen by DeepV
Narender Singh(Nads)Narender Singh(Nads)
Hi,
You can do something like this:
 
<apex:page id="page" standardController="account">
    
    <script>
    	function doEnable(){
            alert('fn called');
            alert(event.currentTarget.value);
            if(event.currentTarget.value===123){
               event.currentTarget.disabled=true;
            }
        }
    </script>
    
    <apex:form id="form" >
        
        <apex:inputField value="{!account.AccountNumber}" onclick="doEnable()" />
        
    </apex:form>
    
</apex:page>
Note: You can switch from enable to disable. But not the other way round.

Let me know if it helps.
Thanks