- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2018 12:02 PM
I want to implement onChange client script for changing the color of additional comment field based on selection of checkbox. Please provide me the solution..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2018 04:47 AM
Hi,
Thank you for your help.
Now it is working with below code.
var c = document.getElementById("activity-stream-comments-textarea");
if (newValue == 'true') {
c.style.backgroundColor = '#FFFFE0';
}
else {
c.style.backgroundColor = '';
}
Thanks,
Dhanashree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2018 12:22 PM
You need to use DOM manipulation. t is on the textarea itself setting the background-color:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2018 12:22 PM
Hi Dhanu,
You can do this using Styles. There are conditions you can apply to a style (if your checkbox is checked, show one background color, if not, show a different background color).
Thanks,
Laurie
Please mark correct or helpful as applicable!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2018 06:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2018 07:13 AM
Hi Dhanashree,
My fault. I gave you bad advice. The condition (Value field) only works on list view. If you leave the Value field blank, then the format in the Style file will apply to both list view and the field in form view.
You will have to use a client script as you originally said. Here is a client script that sets the background color of the incident caller field to blue, if the caller is a VIP. NOTE: this code will NOT work on a mobile platform as it contains DOM manipulation.
function onChange(control, oldValue, newValue, isLoading) {
var callerField = $('sys_display.incident.caller_id');
if (!callerField)
return;
if (!newValue) {
callerField.setStyle({color: ""});
return;
}
g_form.getReference('caller_id', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerField = $('sys_display.incident.caller_id');
if (!callerField)
return;
//check for VIP
if (caller.vip == 'true') {
if (document.documentElement.getAttribute('data-doctype') == 'true')
callerField.setStyle({background-color: "blue"});
}
else {
callerField.setStyle({color: ""});
}
}
You may have to tweak this a little. Hope it helps.
Thanks,
Lauire
Please mark correct or helpful as applicable!