Hi Chris,
In this case you can use a calculated field, and conditional statements in the equation to identify the choice selected. For example, suppose that the fieldname1 field is a DropDown field with the courses names: Course A, Course B, and Course C, and then in the equation you can check the choice selected, and return the corresponding description:
(function(){
var f1 = fieldname1;
if(f1 == 'Course A') return 'Description for the Course A';
if(f1 == 'Course B') return 'Description for the Course B';
if(f1 == 'Course C') return 'Description for the Course C';
})()
or even better:
(function(){
var f1 = fieldname1;
switch(f1){
case 'Course A': return 'Description for the Course A'; break;
case 'Course B': return 'Description for the Course B'; break;
case 'Course C': return 'Description for the Course C'; break;
}
})()
Best regards.
Thanks for the great response!
switch/case works a treat.
One last question on this.
I have number values on some of the dropdowns as I have to calculate costs of the courses etc. I have noticed that the ‘case’ is reading the ‘value’ and not the ‘text’ part of the dropdown. Is it possible that the ‘case’ can read the ‘text’ instead of the ‘value’?
Regards and thanks again,
Chris
Hi,
In this case you should apply some tricks in the equation:
1. Assigns a class name to the DropDown field (for example: my-field)
Note: The class names are assigned to a field through the attribute: “Add Css Layout Keywords”
2. Modify the equation as follows:
(function(){
var tmp = fieldname1;
var f1 = jQuery('.my-field option:selected').attr('vt');
switch(f1){
case 'Course A': return 'Description for the Course A'; break;
case 'Course B': return 'Description for the Course B'; break;
case 'Course C': return 'Description for the Course C'; break;
}
})()
The first line in the equation has not a direct use (var tmp = fieldname1;) however, this line of the code indicates to the plugin that the equation should be evaluated each time that is selected a different option in the fieldname1 field.
Best regards.
Thanks again for the great support.
Will try this out.
Regards
Chris