Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Field Color-Coding Based on Choice Values

## Purpose
Dynamically change the background color of any choice field on a form based on the selected backend value.

## How to Use
1. Create an OnChange client script on the desired choice field.
2. Replace `'your_field_name'` in the script with your actual field name.
3. Update the `colorMap` with relevant backend choice values and colors.
4. Save and test on the form.

## Key Points
- Works with any choice field
- Uses backend values of choices for mapping colors.

## Demo

<img width="1710" height="557" alt="image" src="https://github.com/user-attachments/assets/9fb9e68a-1ade-4eb5-81cc-c947c970bd6f" />

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function onChange(control, oldValue, newValue, isLoading) {

var colorMap = {
'1': '#e74c3c', // Critical - strong red
'2': '#e67e22', // High - bright orange
'3': '#f1c40f', // Moderate - yellow
'4': '#3498db', // Low - blue
'5': '#27ae60' // Planning - green
};

var priorityField = g_form.getControl('priority');
if (!priorityField) return;

priorityField.style.backgroundColor = colorMap[newValue] || '';
}
Loading