Wednesday, April 11, 2012

Get values of form field in javascript from a visualforce page

<apex:page >
    <apex:form id="myForm1">
        <apex:pageblock id="pb1">
            <apex:pageblockSection id="pbs1">
                <apex:inputCheckbox id="checkbox1" label="Check Me" onclick="javascript:getCheckBoxValue();">
                </apex:inputCheckbox>
            </apex:pageblockSection>
        </apex:pageblock>
    </apex:form>
    <script language="javascript">
        function getCheckBoxValue() {
            alert(document.getElementById('{!$Component.myForm1.pb1.pbs1.checkbox1}').checked);   
        }
    </script>
</apex:page>

No comments:

Post a Comment