You need to sign in to do that
Don't have an account?
Ravindar Admin
How to display the field using javascript?
I have 4 fields: 1)Gender__c 2) Date_of_birth__c 3) Age__c 4) Field4__c
My condition is: If (Gender__c='Female' & Age__c>12) Then display the field4__c.
I tried with the following code, It is displaying When I select the gender='female' & if I enter the value manually which meets the condition: age>12 .
I wrote another Javascript with @RemoteAction to update Age__c when I select the Date_of_birth__c.
It is not displaying the field4__c, If the Age__c is updated from date_of_birth__c.
Code is:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript">
var displayField4 = function() {
var genderVal = $( "[id*='inpFldGender']" ).val();
var ageVal = $( "[id*='inpFldAge']" ).val();
if( genderVal === 'Female' && ageVal > 12 ) {
$( "[id*='inpFld4']" ).show();
$( "[for*='inpFld4']" ).show();
}
else {
$( "[id*='inpFld4']" ).hide();
$( "[for*='inpFld4']" ).hide();
}
};
displayField4();
</script>
My condition is: If (Gender__c='Female' & Age__c>12) Then display the field4__c.
I tried with the following code, It is displaying When I select the gender='female' & if I enter the value manually which meets the condition: age>12 .
I wrote another Javascript with @RemoteAction to update Age__c when I select the Date_of_birth__c.
It is not displaying the field4__c, If the Age__c is updated from date_of_birth__c.
Code is:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript">
var displayField4 = function() {
var genderVal = $( "[id*='inpFldGender']" ).val();
var ageVal = $( "[id*='inpFldAge']" ).val();
if( genderVal === 'Female' && ageVal > 12 ) {
$( "[id*='inpFld4']" ).show();
$( "[for*='inpFld4']" ).show();
}
else {
$( "[id*='inpFld4']" ).hide();
$( "[for*='inpFld4']" ).hide();
}
};
displayField4();
</script>
Apex Controller Extension
Visualforce
I hope this works. If you have any queries, feel free to come back.
All Answers
Apex Controller Extension
Visualforce
I hope this works. If you have any queries, feel free to come back.