Calculated field value
Posted by stieland - Jun 17 ’13 at 12:43
I have a calculated field on the form. I am looking for how to do the following on both the Display and Edit forms:
- Get the value of the calculated field
- Set the background color of the calculated field based off of the value - if below 50 set background to red, 51-99 set to yellow, 100 set to green
- Set the value of the calcuated field based off of actions on the form
-
DmitryAdminMember for: 11 years 3 months 16 days
Hello,
I have created a simple example for you. First, I created a new custom list with three column: A (number), B (number), SUM (calculated field: A + B). In Forms Designer I added my fields into the form and set css-class of SUM field to 'calc-field'. I will use this class in selector to set background-color:
Next, I declared the following CSS classes in Forms Designer's CSS-editor:
.bg-red { background-color: red; } .bg-green { background-color: green; } .bg-yellow { background-color: yellow; }
I will use them to set background color based on the SUM field value. Next, I added the following js-code to JS-editor:
function setBgColor() { $('.calc-field').removeClass('bg-red bg-yellow bg-green') var calcValue = parseFloat(fd.field('SUM').control()._el().text()); if (calcValue <= 50) { $('.calc-field').addClass('bg-red'); } if (calcValue > 50 && calcValue < 100) { $('.calc-field').addClass('bg-yellow'); } if (calcValue == 100) { $('.calc-field').addClass('bg-green'); } } function updateSum() { var a = parseFloat(fd.field('A').control().value()); var b = parseFloat(fd.field('B').control().value()); fd.field('SUM').control()._el().html(a + b); setBgColor(); } // updates calculated field value when value of field A is changed. fd.field('A').control().change(function() { updateSum(); }); // updates calculated field value when value of field B is changed. fd.field('B').control().change(function() { updateSum(); }); // sets background color of SUM field setBgColor();
setBgColor function changes background of the calculated field based on its value. updateSum updates value of SUM field based on the current values of A and B and changes its background color. I call this function when value of the field A or B is changed. And in the latest line I call setBgColor to set initial background color of SUM field.
To get detailed description of Forms Designer's JS-framework, please, follow the link:
http://spform.com/documentation/js/manager -
stielandMemberMember for: 10 years 3 months 13 days
Perfect, thanks. I could not have asked for a better example.
-
KatlerMemberMember for: 2 months 24 days
Po mneniyu analitikov, samym deshevym dlya TV-zriteley budet match mezhdu Italiyey i Rossiyey – on sostoitsya na Khel'sinki-arene 18 maya. Samoye dorogoye – vstrecha Kanady i Rossii v poslednem gruppovom etape. Analitiklərin fikrincə, televiziya tamaşaçıları üçün ən ucuz qarşılaşma mayın 18-də Helsinki Arenada baş tutacaq İtaliya - Rusiya matçı olacaq. Ən bahalısı isə son qrup mərhələsindəki Kanada və Rusiya görüşüdür mostbet yukle
-
Riyanasharma01MemberMember for: 1 month 22 days
Get a stunning girl from Udaipur Escort Service, and she will provide you with all the services you require; all you have to do is arrange a meeting with her.
Puri Escort Service || <> || Rayagada Escort Service || <> || Sambalpur Escort Service || <> || Sonepur Escort Service || <> || Sundargarh Escort Service || <> || Amritsar Escort Service || <> || Barnala Escort Service || <> || Bathinda Escort Service || <> || Fazilka Escort Service || <> || Faridkot Escort Service || <> || Fatehgarh Sahib Escort Service || <> || Firozpur Escort Service || <> || Gurdaspur Escort Service || <> || Hoshiarpur Escort Service || <> || Jalandhar Escort Service || <> || Kapurthala Escort Service || <> || Ludhiana Escort Service || <> || Mansa Escort Service || <> || Moga Escort Service || <> || Mohali Escort Service || <> || Muktsar Escort Service || <> || Pathankot Escort Service || <> || Patiala Escort Service || <> || Rupnagar Escort Service || <> || Sangrur Escort Service || <> || Shahid Bhagat Singh Nagar Escort Service || <> || TarnTaran Escort Service || <> || Gangtok Escort Service || <> || Mangan Escort Service || <> || Namchi Escort Service || <> || Geyzing Escort Service || <> || Ariyalur Escort Service || <> || Chengalpattu Escort Service || <> || Chennai Escort Service || <> || Coimbatore Escort Service || <> || Cuddalore Escort Service || <> || Dharmapuri Escort Service || <> || Dindigul Escort Service || <> || Erode Escort Service || <> || Kallakurichi Escort Service || <> || Kanchipuram Escort Service || <> || Kanniyakumari Escort Service || <> || Karur Escort Service || <> || Krishnagiri Escort Service || <> || Madurai Escort Service || <> || Nagapattinam Escort Service || <> || Namakkal Escort Service || <> || Nilgiris Escort Service || <> || Perambalur Escort Service || <> || Pudukkottai Escort Service || <> || Ramanathapuram Escort Service || <> || Ranipet Escort Service || <> || Salem Escort Service || <> || Sivaganga Escort Service || <> || Tenkasi Escort Service || <> || Thanjavur Escort Service || <> || Theni Escort Service || <> || Thoothukudi Escort Service || <> || Tiruchirappalli Escort Service || <> || Tirunelveli Escort Service || <> || Tirupattur Escort Service || <> || Tiruppur Escort Service || <> || Tiruvallur Escort Service || <> || Tiruvannamalai Escort Service || <> || Tiruvarur Escort Service || <> || Vellore Escort Service || <> || Viluppuram Escort Service || <> || Virudhunagar Escort Service || <> || Lakshadweep Escort Service || <> || Amini Escort Service || <> || Andrott Escort Service || <> || Kadmat Escort Service || <> || Kalpeni Escort Service || <> || Kavaratti Escort Service || <> || Minicoy Escort Service || <> || Karaikal Escort Service || <> || Mahe Escort Service || <> || Puducherry Escort Service || <> || Yanam Escort Service || <> || Goa Escort Service || <> || Panaji Escort Service || <> || Margao Escort Service || <> || Daman Escort Service || <> || Diu Escort Service || <> || Dadra haveli Escort Service || <> || Andamand & Nicobar Escort Service || <> || Portblair Escort Service || <> || Agra Escort Service || <> || Aligarh Escort Service || <> || Allahabad Escort Service || <> || Ambedkar Nagar Escort Service || <> || Amethi Escort Service || <> || Amroha Escort Service || <> || Auraiya Escort Service || <> || Azamgarh Escort Service || <> || Badaun Escort Service || <> || Bahraich Escort Service || <> || Ballia Escort Service || <> || Balrampur Escort Service || <> || Banda Escort Service || <> || Barabanki Escort Service || <> || Bareilly Escort Service || <> || Basti Escort Service || <> || Bijnor Escort Service || <> || Bulandshahr Escort Service || <> || Chandauli Escort Service || <> || Chitrakoot Escort Service || <> || Deoria Escort Service || <> || Etah Escort Service ||
-
harrybrookMemberMember for: 2 months 7 days
In database management, calculated fields offer an elegant way to derive insights from existing data. I use them to create dynamic reports that automatically update as the source data changes.