• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

If then scenarios to highlight multiple dropdown boxes

New Here ,
Nov 27, 2024 Nov 27, 2024

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?  

 

TOPICS
JavaScript , PDF

Views

194

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2024 Nov 27, 2024

Copy link to clipboard

Copied

By "highlight" do you mean something like change the fill color from white to yellow?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 29, 2024 Nov 29, 2024

Copy link to clipboard

Copied

Yes, Correct

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 29, 2024 Nov 29, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 29, 2024 Nov 29, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2024 Dec 02, 2024

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;}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2024 Dec 02, 2024

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" ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2024 Dec 02, 2024

Copy link to clipboard

Copied

Thank You...that Worked!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2024 Dec 02, 2024

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;}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2024 Dec 02, 2024

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2024 Dec 02, 2024

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. 

 

laura_6291_0-1733161180401.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2024 Dec 02, 2024

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2024 Dec 02, 2024

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2024 Dec 02, 2024

Copy link to clipboard

Copied

LATEST

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;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines