Copy link to clipboard
Copied
I am trying to figure out the script for highlighting multiple box when one items is choosen .
For Example,
If I choose "DDA" in dropdown1 then I want Dropdown8, Dropdown15 and dropdown 18 to be highlighted in yellow.
How do I write this script?
Copy link to clipboard
Copied
By "highlight" do you mean something like change the fill color from white to yellow?
Copy link to clipboard
Copied
Yes, Correct
Copy link to clipboard
Copied
You can use this code as the custom Validation script of the drop-down:
var DDAfields = ["Dropdown8", "Dropdown15", "dropdown 18"];
for (var i in DDAfields) {
var f = this.getField(DDAfields[i]);
f.fillColor = (event.value=="DDA") ? color.yellow : color.white;
}
I used the names you provided, but be aware they must match the actual field names EXACTLY for it to work, including lower-/upper-case letters, spaces, etc.
Copy link to clipboard
Copied
Please note that if field highlighting is enabled, the fill color will not be visible until the field is selected (or set to read-only). In such cases, it may be more effective to highlight the border color instead of the fill color.
To implement this, simply replace fillColor
with strokeColor
.
Copy link to clipboard
Copied
Thank you, I like the Highlight border works best for the form I'm working on. This script worked for my fist option of DDA.
var Dropdown1fields = ["Dropdown5", "Dropdown6","Dropdown8","Dropdown9","Dropdown10","Dropdown15","Dropdown17","Dropdown18","Dropdown19","Dropdown21","Dropdown23","Dropdown25","Dropdown27","Dropdown29","Dropdown33","Dropdown35","Dropdown37","Dropdown38","Dropdown39","Dropdown40"]; for (var i in DDAfields) {var f = this.getField(DDAfields[i]); f.strokeColor = (event.value=="DDA") ? color.yellow : color.white;}
Now I want to change DDA to SAV. So if they change options. This is what my script says but it is not working. What did I miss?
var Dropdown1fields = ["Dropdown5", "Dropdown6","Dropdown8","Dropdown9","Dropdown10","Dropdown15","Dropdown17","Dropdown18","Dropdown19","Dropdown21","Dropdown23","Dropdown25","Dropdown27","Dropdown29","Dropdown33","Dropdown35","Dropdown37","Dropdown38","Dropdown39","Dropdown40"]; for (var i in SAVfields) {var f = this.getField(SAVfields[i]); f.strokeColor = (event.value=="DDA") ? color.yellow : color.white;}
Copy link to clipboard
Copied
If you're going to rename the array variable then you need to do it consistently throughout the code.
Also, you of course need to adjust the string in event.value=="DDA" to event.value=="SAV" ...
Copy link to clipboard
Copied
Thank You...that Worked!!!
Copy link to clipboard
Copied
Now I have another problem. The SAV is working but not the DDA. This is my string. Do I have to but something special between the two strings to get them both to work?
var Dropdown1fields = ["Dropdown5", "Dropdown6","Dropdown8","Dropdown9","Dropdown10","Dropdown15","Dropdown17","Dropdown18","Dropdown19","Dropdown21","Dropdown23","Dropdown25","Dropdown27","Dropdown29","Dropdown33","Dropdown35","Dropdown37","Dropdown38","Dropdown39","Dropdown40"]; for (var i in Dropdown1fields) {var f = this.getField(Dropdown1fields[i]); f.strokeColor = (event.value=="DDA") ? color.yellow : color.white;}var Dropdown1fields = ["Dropdown5", "Dropdown6","Dropdown8","Dropdown9","Dropdown10","Dropdown15","Dropdown17","Dropdown18","Dropdown19","Dropdown21","Dropdown23","Dropdown25","Dropdown27","Dropdown29","Dropdown33","Dropdown35","Dropdown37","Dropdown38","Dropdown39","Dropdown40"]; for (var i in Dropdown1fields) {var f = this.getField(Dropdown1fields[i]); f.strokeColor = (event.value=="SAV") ? color.yellow : color.white;}
Copy link to clipboard
Copied
You have the same field names in both, so the latter overrides the former...
Do you mean that they will be highlighted if either "DDA" or "SAV" are selected?
Copy link to clipboard
Copied
So Yes, the field it self is named Dropdown1 but there is muliple options they could select in that field. DDA, SAV etc.
Copy link to clipboard
Copied
But the question is if you want to highlight those other drop-downs in the same way if either DDA or SAV are selected in that drop-down?
Copy link to clipboard
Copied
Yes, however when I get down to CD, LAS etc they will have other boxes highlighted. Not the same ones as DDA and SAV.
Copy link to clipboard
Copied
Then you need to use something like this:
var Dropdown1fields = ["Dropdown5", "Dropdown6", "Dropdown8", "Dropdown9", "Dropdown10", "Dropdown15", "Dropdown17", "Dropdown18", "Dropdown19", "Dropdown21", "Dropdown23", "Dropdown25", "Dropdown27", "Dropdown29", "Dropdown33", "Dropdown35", "Dropdown37", "Dropdown38", "Dropdown39", "Dropdown40"];
for (var i in Dropdown1fields) {
var f = this.getField(Dropdown1fields[i]);
f.strokeColor = (event.value == "DDA" || event.value == "SSA") ? color.yellow : color.white;
}
var Dropdown2fields = [ ... ]; // Insert field names for "CD"
for (var i in Dropdown2fields) {
var f = this.getField(Dropdown2fields[i]);
f.strokeColor = (event.value == "CD") ? color.yellow : color.white;
}
var Dropdown3fields = [ ... ]; // Insert field names for "LAS"
for (var i in Dropdown3fields) {
var f = this.getField(Dropdown3fields[i]);
f.strokeColor = (event.value == "LAS") ? color.yellow : color.white;
}