Copy link to clipboard
Copied
I have set the items in the dropdown list as follows.
var l = this.getField("Dropdown1");
l.setItems(["One", "Two", "Three"]);
This will certainly show "One", "Two", "Three" in the drop down list.
However, when actually using it, for some reason only "One" can be selected.
Even if I select "Two", "One" is displayed.
I created a button for trial and wrote the code there.
In this case, it worked as planned.
Why can't I just write the code directly in the drop-down list?
Is it possible to achieve the goal without creating a new button?
This kind of code only needs to execute once, or when the options change. When you use setItems it resets the field to the default value (the first item in the list), which is probably what is happening in your case.
Copy link to clipboard
Copied
Where in the dropdown list does you use the script?
Copy link to clipboard
Copied
Where to enter the formula on the Options tab of the drop-down list field.
Copy link to clipboard
Copied
This kind of code only needs to execute once, or when the options change. When you use setItems it resets the field to the default value (the first item in the list), which is probably what is happening in your case.
Copy link to clipboard
Copied
The point is that what I want to do is impossible. I can understand what you say. Thank you very much.
Copy link to clipboard
Copied
I don't know what you want to do, but that's not what I said...
Copy link to clipboard
Copied
Hello try67.
I have the same problem here. And I don't know how to solve. Can you help me, please.
//Two checkbox
var a = getField("acessoAMagiasArcano").value;
var d = getField("acessoAMagiasDivino").value;
//One dropdown list just to help me with ".cleatItems()"
var c = getField("Classe").value;
var cM = '';
//My dropdown list "cML_01"
if(c == "Classe" || c == " ") this.getField("cML_01").clearItems();
if(a == "No" && d == "No") cM = '';
else{
if(a == "Yes") cM = ["CÃrculo", "", "1º", "2º", "3º", "4º", "5º", "6º", "7º", "8º", "9º"];
else if(d == "Yes") cM = ["CÃrculo", "", "1º", "2º", "3º", "4º", "5º", "6º", "7º"];
else cM = '';
}
if(cM != '') this.getField("cML_01").setItems(cM);
Then, I have two issues:
1º - The list only appears after I click on dropown. I saw that the solution is check the option "Commit selected value immediately". I already have this option cheked and doesn't work.
2º - The list is created as:
CÃrculo
1º
2º
3º
When I click on "1º" (for example) my pdf take a long time loading then move back to "CÃrculo". Always. I have 17 equal fields, so I don't know how to use the dropdown "Classe" do populate my all 17 "cML" dropdow. 😞
Could you help me, please?