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
harish reddy 39harish reddy 39 

How to sum picklist values in controller and pass it to visuvalforce page

I have three picklist values picklist1,picklist2,picklist3 all picklist containing values 1-10, based on these picklist values in have to highlight a section of a VF.I am trying to add picklist values so that values so that I can use them as standard for each section of VF page when combination falls in any one of the standard it should highlight that perticular section.
i am trying but couldn't get it done.can some one help me with that.
Thanks in advance.
jigarshahjigarshah
Harish,

Is the summation expected to happen as the picklist values are set on the page considering that the Visualforce page you are building allows the User to modify the values? If this is not the case, and the picklist values are already set and you just need to highlight a specific section, you can create a custom formula field to sum the picklist field values on the Sobject record.

Formula for the custom field would be as follows.
VALUE(TEXT(Picklist1__c)) 
+ VALUE(TEXT(Picklist2__c)) 
+ VALUE(TEXT(Picklist3__c))
And when you load the page, based on the value within the custom formula field highlight the respective section.

If the values need to be set at runtime, pass the selected picklist values to a Javascript method using an onChange event. Use the Javascript method to compute the sum of the selected values. Use the values to hide / show or highlight the appropriate panel. If you can share the code of your existing page I can help you address the issue.