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
neshnesh 

conditionally highlight a custom field in VF -Highlight in RED if below 75%

How to highlight a custom field based on condion( Highlight in RED if below 75% ).

custom field name:Total Grade.(data type :percentage )

my vf page code:

<apex:pageblockSection title="Total Grade">

<apex:outputField value="{!newapp.Total_grade_1__c}" styleclass="{!if((newapp.Total_grade_1__c<75), 'color:red', '')}" /

</apex:pageblockSection>

above code doesnt work. my custom field data type is percentage...Please help me.

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi Nesh,

 

You can do this by direct rendering option in vf page or by using javascript. 

 

Try the following using rendered option in output field.

<apex:pageblockSection title="Total Grade">

<apex:outputField value="{!newapp.Total_grade_1__c}" rendered="{!newapp.Total_grade_1__c < 75}" style="color:red;" />

<apex:outputField value="{!newapp.Total_grade_1__c}" rendered="{!newapp.Total_grade_1__c > 75}" />

</apex:pageblockSection>

 

otherwise use javascript,


<apex:page>

...........................

<script>

      function showhide(){

           if(document.getElementByID("{!$Component.totalgrade}").value > 75){

                 document.getElementByID("{!$Component.totalgrade}").style.display = "red";

           }

           else{

                 document.getElementByID("{!$Component.totalgrade}").style.display = "none";

            }

     }

</script>

................

<apex:form>

.....

<apex:pageblockSection title="Total Grade">

<apex:outputField value="{!newapp.Total_grade_1__c}" style="display:none;" />

</apex:pageblockSection>

......

<apex:commandButton value="save" action="{!save}" onclick="return showhide();" />

</apex:form>

<apex:page>

 

 

Hope so this helps you...!

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

 

 

 

neshnesh

ABOVE TWO CONDITION DOESNT WORK...

My Requirement: total grade fielld update from workflow rule----data type -percentage.

Highlight in RED if below 75%---total grade=56%

If above 75% display like-Total GRADE=80%

neshnesh

How to call  apex class from List View Custom Button  ..my inside apex class code is here- how to use it...Please help me

INSIDE CLASS:
List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          {
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }