Change the colour of a checkbox field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 07:08 AM
Hello Experts,
I have a requirment to change the colour of a check box(True/False) type field, when the filed is checked.
If the check box is checked , the colour of the filed name and the check box should turn to 'red' colour. and it should turn back to black when it is unchecked.
Let me know, how to achieve this.
Thank you,
Ramkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 07:12 AM
Hi Ram,
Check this out:
https://www.w3schools.com/howto/howto_css_custom_checkbox.asp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 10:45 AM
Hi Anurag,
I was able to change the field label by using the below client script. But I want the check box (container) colour should also get changes when the check box got ticked.
Here, is the on change client script which changes the label colour.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var bsc = g_form.getValue('u_business_critical');
var incidentbsc = document.getElementById('label.incident.u_business_critical');
if (bsc == 'true'){
incidentbsc.style.color = "red";
}
else{
incidentbsc.style.color = "black";
}
}
** I want know how to change the check box container colour to red.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 11:07 AM
You can achieve this using Client Script:
g_form.getControl('checkbox').parentNode.style.color = 'red'
just as it was mentioned here:
https://community.servicenow.com/community?id=community_question&sys_id=c5f117eddbdcdbc01dcaf3231f96193d
REgards,
Sachin