You need to sign in to do that
Don't have an account?
Disable or Enable fields depending on Checkbox Selection
Hi,
My req is that ,when a checkbox is checked then 4 fields(3 text fields and 1 picklist field) needs to be enabled or else it should be disabled.
I have achieved this functionality with 3 text fields,but i am facing problem in Picklist field since i am unable to do enable/disable.
Below is the Code:
<apex:inputField value="{!Liabilities__c.Type_of_Loan__c}" id="loanType"/> // PICKLIST FIELD//
<apex:inputText value="{!Liabilities__c.Loan_Amount__c}" disabled="{!NOT(Liabilities__c.Loan_Taken__c)}" />
<apex:inputText value="{!Liabilities__c.Loan_Tenure_Years__c}" disabled="{!NOT(Liabilities__c.Loan_Taken__c)}" />
<apex:inputText value="{!Liabilities__c.EMI__c}" disabled="{!NOT(Liabilities__c.Loan_Taken__c)}" id="EMI"/>
Please help me in this context.
Thanks in Advance.
Regards,
Rabi
you can try this
this will open the picklist once you select the checkbox and by default this is disabled
Hi Kiran,
Below is my Code: But i am not achieving the Enable/Disable Functionality.
<apex:inputcheckbox value="{!account.Eat_Fruits__c}" id="test" onclick="check(this)" />
<apex:inputField value="{!account.Class__c}" id="testing" />
<script> document.getElementById('j_id0:j_id1:j_id2:j_id3:testing').disabled=true;</script>
<script>
var v=document.getElementById("j_id0:j_id1:j_id2:j_id3:test").checked;
function check(obj)
{
if((v==true)){
document.getElementById("j_id0:j_id1:j_id2:j_id3:testing").disabled=false;
}
else{
document.getElementById("j_id0:j_id1:j_id2:j_id3:testing").disabled=true;
}
}
Can you please rectify me,where am i going Wrong.
Regards,
Rabi
<apex:inputcheckbox value="{!account.Eat_Fruits__c}" id="test" onchange="check(this)" />
<apex:inputField value="{!account.Class__c}" id="testing" />
<script> document.getElementById('{!$component.testing}').disabled=true;</script>
<script>
function check(obj)
{
if((obj.checked == true)){
document.getElementById("{!$component.testing}").disabled=false;
}
else{
document.getElementById("{!$component.testing}").disabled=true;
}
}
Sorry Kiran...still its not working.
Regards,
Rabi
<apex:page standardController="account">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputcheckbox value="{!account.Eat_Fruits__c}" id="test" onclick="check(this)" />
<apex:inputField value="{!account.Class__c}" id="testing" />
<script> document.getElementById('j_id0:j_id1:j_id2:j_id3:testing').disabled=true;</script>
<script>
<script>
function check(obj)
{
if((account.Eat_Fruits__c.checked == true)){
document.getElementById('j_id0:j_id1:j_id2:j_id3:testing').disabled=false;
}
else{
document.getElementById('j_id0:j_id1:j_id2:j_id3:testing').disabled=false;
}
}
else{
document.getElementById('j_id0:j_id1:j_id2:j_id3:testing').disabled=true;
}
</script>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Regards,
Rabi
just use the below code as it is
Still Not Working ... :-(
will this work for you...