+ Start a Discussion
test269test269 

disabled the field based on the another field value

Hi all,

   I have three fields in my vf page.as

 

name--->text field,

 

number --->text field

 

option---->check box

 

In this whenever i check the option checkbox then name will be in disabled mode.How can we do this.Any one can help me.

 

 

 

 

 

 

 

 

 

 

 

 

thanks in advance

Navatar_DbSupNavatar_DbSup

Hi,

Try the below code snippet as reference:

 

<apex:page controller="sampleCon" tabStyle="Opportunity" id="thepage">

 

<script>

   function disablechbx()

    {

    if(document.getElementById('{!$Component.thepage.theform.thepageblock.out.chkbx}').checked== true)

    document.getElementById('{!$Component.thepage.theform.thepageblock.out.inputc}').disabled=true;

    else

    document.getElementById('{!$Component.thepage.theform.thepageblock.out.inputc}').disabled=false;

   

    }

   

</script>

 

        <apex:form id="theform">

 

        <apex:pageBlock id="thepageblock">

 

        <apex:pageBlockSection collapsible="true" title="list" >

 

 

       <apex:pageBlockSection id="out">

 

        <apex:inputCheckbox id="chkbx"  onclick="disablechbx();"/>

        <apex:inputText id="inputc" value="{!}"/>

    

       </apex:pageBlockSection>

 

     

      </apex:pageBlock>

 

      </apex:form>

 

 

</apex:page>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

test269test269

thank you for your replay.

its not working any action