There is the following code that identifies the layouts in a PDF document when the values ​​match. The problem is that only the first label will appear, in the example it has indicated two but only the first appears. In my code, about 40 if ... else syntaxes, in some I need to identify 8 Leibs at a time. I drove all the laybs into the fields array and then hide and show them in the document, depending on the user's choice in the form of a value, if the values ​​match, then show certain laybs and hide the rest. Would be very grateful if someone suggested what is wrong with the code and how can it be changed?

 var countryofgrowth = this.getField("countryofgrowth").value; var type = this.getField("type").value; var AcceptableCountries = ["Aland Islands [AX]", "Alderney", "American Samoa [AS]", "Andorra [AD]", "Anguilla [AI]", "Antarctica [AQ]", "Australia [AU]", "Belgium [BE]", "Canada [CA]", "Czech Republic [CZ]", "Denmark [DK]"]; function setDisplay(item) { var fields = ["sugarlabel", "goodsugar", "sugarQualitylevellow" /*,...*/]; for(var i=0; i< fields.length; i++){ if(fields[i] == item) { getField(fields[i]).display=display.visible; } else { getField(fields[i]).display=display.hidden; } } } if (type == "sugar" && AcceptableCountries.indexOf(countryofgrowth) != -1) { setDisplay("sugarlabel") setDisplay("goodsugar") } 

Something like this is my form. In each drop-down menu, the user selects values, and if certain values ​​match, certain laybs should be seen in the document.

enter image description here

  • Please concretize - edit the post: what you pull out from pdf data, what library is used. It is not clear what "syntax and its coincidence" means. Well, the obvious cant - in one place you have this.getField called in the second, just getField is a different call. - Goncharov Alexander
  • Hello Alexander, changed the post and I hope now the situation is clearer. I would be grateful for your help. - o0Lucky0o
  • I can tell you a little, because I do not even know the library that you use to read pdf. At least I will repeat about the error this.getField from the top, inside the getField just getField : you need to make a var self = this; and inside the self.getField(...) call self.getField(...) . And then, as it were, they are not asking for the code to be debugged for you - how to do this is written in the corresponding articles, and you can be asked to do it on other portals. Here they ask conceptual questions that are not available even in English. - Goncharov Alexander
  • Alexander, I do not use any library, the code is in the document itself. I am not a pro in programming, and even more so in javascript. I thought they were helping to solve problems with the code, I’m not sure how to help with the problem without writing code that solves the problem, I don’t know more than other forums, because this is the most popular one here. I wrote the whole concept of my code from above, I'm not sure about which library I am talking about ... Direct at least in the right direction? - o0Lucky0o

0