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
DeepikareddyDeepikareddy 

How to get the values to pass form inputtext to javascript

 <apex:pageblock id="pb1">
            <apex:pageblockSection id="pbs1">
                <apex:inputCheckbox id="checkbox1" label="Check Me" onclick="getCheckBoxValue();"></apex:inputCheckbox>
                <apex:inputtext id="textbox1" label="Name" onchange="gettexBoxValue();"/>
            </apex:pageblockSection>
        </apex:pageblock>
    
    <script language="javascript">
        function getCheckBoxValue()
        {
        
           
           alert(document.getElementById('{!$Component.frm1.pb1.pbs1.checkbox1}').checked);  
        }
        
         function gettexBoxValue()
        {
          
           var a=document.getElementById('{!$Component.frm1.pb1.pbs1.textbox1}');
            alert(a);  
        }
       //if iam using this iam getting.  
        function CopySubject() {
      var CaseSub= $('[id$=textbox1]').val();
       alert(CaseSub); 
       }
    </script>
Sahil ShitoleSahil Shitole
Hi Deepika,

You can use class attribute instead of Id to get the value.

 <apex:inputtext styleClass="textbox1" label="Name" onchange="gettexBoxValue();"/>

In the JS you use:
document.getElementsByClassName('textbox1')[0].value

Thanks