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
vanita kumarivanita kumari 

Toggle the checkbox

Hi All,

I am new to slesforce. i have created a stadard object and creating the Visual force page for he same. I have 2 checkboxes., on clicking the first one, second should become disable/Hide.

i m using the change jquery event when first check box is selected nd trying to toggle the second checkbox. But my change event is not getting called. 

I m not ble to find the exact reson. Please hve a look on the code.


<apex:page standardController="Batch__c" >
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(document).ready(function(){
alert('testfirst');
$("#studentnoptification").change(function(){  ===> control not reaching here
alert('test');
$("#isprof").toggle();
});
});
</script>
<apex:form >
<apex:pageBlock>
<apex:pageBlockSection id="pbSection1" columns="1">
<apex:inputfield value="{!Batch__c.Name}" id="Bus" required="true"/>
<apex:inputfield value="{!Batch__c.isstudent__c}" id="studentnoptification"/>
<apex:inputfield value="{!Batch__c.Lab_Timing__c}" required="true"/>
<apex:inputfield value="{!Batch__c.isproffessional__c}" id="isprof"/>
</apex:pageBlockSection>
<apex:pageBlockButtons > <apex:commandbutton value="Save" action="{!save}"></apex:commandbutton> <apex:commandbutton value="Save & new" action="{!quicksave}"></apex:commandbutton> <apex:commandbutton value="Cancel" action="{!cancel}"></apex:commandbutton>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>


Thanks in Advance
 
Best Answer chosen by vanita kumari
Roy LuoRoy Luo
If you inspect the element at browser, you will see sfdc add tons of prefix to the Id. Try this:

change $("#studentnoptification").change(function(){})

to

$('[id$="studentnoptification"]').change(function(){})