I am trying to render a component as read-only or editable based on a check-box value. The code I have used is given below.
<apex:pageBlockSection title="Relation Iformation" columns="2" id="information">
<apex:inputField value="{!kpiRelation.KPI_Library__c}">
<apex:actionSupport event="onchange" action="{!UpdatePageWithKPI}" oncomplete="RenderPanels()" reRender="pageBlock" />
</apex:inputField>
<apex:inputField label="Edit KPI Treshold?" value="{!kpiRelation.Edit_KPI__c}" rendered="{!kpiRelation.KPI_Library__c != ''}" id="editKpi" onchange="RenderConditions(this)"/>
</apex:pageBlockSection>
In the above code the Edit KPI threshold is a check box value. I have the below JavaScript to capture the check box value.
function RenderConditions(data) {
var checkBox = {!kpiRelation.Edit_KPI__c};
if(data != '')
alert('The edit kpi -- '+data.value);
if (data == 1){
document.getElementById('{!$Component.pageBlock.condtNum}').style.display ='block';
}else{
document.getElementById('{!$Component.pageBlock.condtNum}').style.display ='none';
}
}
But when I change the value, the value I am selecting is not getting updated in the script. Can anyone tell me what I am doing wrong here?
Best Answer
Instead of using:
you would check like it: