function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RakeebRakeeb 

Kindly Read the following Scenario

HI, i have checkbox and text dataype i.e status and points, if the status is active then it will enable the point text field  otherwise it should be disable the textbox (points) ,so how can i do the validation so kindly let me know ASAP.

ANKITAANKITA

<!-- enable Or Disable the Javascript Components using Checkboxes -->
<apex:page id="p1">
  <script language="javascript">
      function js()
      {
          var c=document.getElementById("check1").checked;
          alert(c);
         if(c)
         {
             document.getElementById("email").disabled=true;
         }
         else
         {
             document.getElementById("email").disabled=false;
         }
      }
  </script>
  <apex:form id="f1">
  <input type="checkbox" id="check1" onclick="return js();"/>
      <input type="text" id="email" />
  </apex:form>
</apex:page>

 

This code may be helpful to you.

 

Thanks

Ankita

RakeebRakeeb

Thanks for giving reply,which you have provided a code that is fine  but i want to do customization i.e with out  using code.

Chamil MadusankaChamil Madusanka

Hi Rakeeb,

 

This is a visualforce component version of ANKITA's code.

 

<apex:page id="p1">
  <script language="javascript">
      function js(check,email)
      {
          var c=document.getElementById(check).checked;
          
         if(c)
         {
             document.getElementById(email).disabled=false;
         }
         else
         {
             document.getElementById(email).disabled=true;
         }
      }
  </script>
  <apex:form id="f1">
  
  <apex:inputCheckbox selected="true" id="check1" onchange="js('{!$Component.check1}','{!$Component.email}');" />
  
      <apex:inputText id="email"/>
  </apex:form>
</apex:page>

Just copy and paste in a visualforce page and see what is look like.

 

Chamil's Blog

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

SFDC_LearnerSFDC_Learner

Hi

 

 function js(check,email)



<apex:inputCheckbox selected="true" id="check1" onchange="js('{!$Component.check1}','{!$Component.email}');" />
<apex:inputText id="email"/>

 

Can you please explain me what is the functionality that is working here.

I don't know why we use this.

('{!$Component.check1}','{!$Component.email}'

And how the parameters are passing from here to javascript function.

 

 

Thanks