Copy link to clipboard
Copied
i have a if loop to check some parameters :
var A0 = this.getField("Dropdown14.0").value
var A1 = this.getField("Dropdown14.1").value
var A2 = this.getField("Dropdown14.2").value
var A3 = this.getField("Dropdown14.3").value
var A4 = this.getField("Dropdown14.4").value
.
.
.
var A500 = this.getField("Dropdown14.500").value
if (num1!=0 && A0=="check" && A1!="check" && A2!="check"... A500!="check")
now the problem is A0 go to A500.....
the only solution is to write A0=="check" && A1!="check" && A2!="check"....
any smarter solution?
Copy link to clipboard
Copied
Yes, you can use a simple loop to do it, and there's also no reason to check all the fields because as soon as one of them does not equal the value you're comparing it to then you can stop. However, that can only work if the condition is the same for each field.
What is "num1" and what does it have to do with the rest of the fields, and why is the condition for A0 different for all the rest? Is it the same for 1-500 and only different for 0?
If so, you can use something like this:
var b = (num1!=0 && this.getField("Dropdown14.0").valueAsString=="check");
if (b==true) {
for (var i=1; i<=500; i++) {
var f = this.getField("Dropdown14."+i);
if (f.valueAsString=="check") {
b=false;
break;
}
}
}
if (b==true) {
// do something
} else {
// do something else
}
Copy link to clipboard
Copied
Try67 gave some good ideas on how to solve your problem. I’d like to show you another option. You can store your field values in an array, and then use a calculated array index to reference them:
var A =[];
for (var i=0; i<500; i++) {
A = this.getField(“Dropdown.14.” + i).value;
}
You can then reference any A value in the array using a loop.
Copy link to clipboard
Copied
thanks for this answers team...
Karl heinz Kremer how to check between values in arrays?
var A=["Dropdown14.0","Dropdown14.1"....,"Dropdown14.500"];
this e.g. work?:
if (num1!=0 && this.getField(fields[0]).value=="check" && this.getField(fields[1,10]).value!="check")
i want to check Dropdown14.1.Dropdown14.2,...Dropdown14.10 != check ??
Copy link to clipboard
Copied
Once the values are in an array, one can remove the values that equal "check" by applying a filter to the array. Then one can process the new/revised array of values.
var A =[];
for (var i=0; i<500; i++) {
A = this.getField(“Dropdown.14.” + i).value;
}
function NotCheck(element){
// remove elements not equal to check;
return element != "check";
}
A = A.filter(NotCheck); // apply filter to array;
Copy link to clipboard
Copied
var A0 = this.getField("Dropdown14.0").value
var A1 = this.getField("Dropdown14.1").value
var A2 = this.getField("Dropdown14.2").value
var A3 = this.getField("Dropdown14.3").value
.
.
.
var A52 = this.getField("Dropdown14.52").value
var J1 = this.getField("Text58").value
var num = 0;
var num1 = 0;
var al = user;
var als = users;
.
.
.
if (num!=0 && A0==" check" && A1!=" check" && A2!=" check" && A3!=" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text1").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A0==" check" && A1!=" check" && A2!=" check" && A3!=" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text1").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A1==" check" && A2!=" check" && A3!=" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text2").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A1==" check" && A2!=" check" && A3!=" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text2").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A2==" check" && A3!=" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text3").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A2==" check" && A3!=" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text3").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A3==" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text4").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A3==" check" && A4!=" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text4").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A4==" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check"&& A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text5").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A4==" check" && A5!=" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text5").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A5==" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text6").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A5==" check" && A6!=" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text6").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A6==" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text7").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A6==" check" && A7!=" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text7").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A7==" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text8").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A7==" check" && A8!=" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text8").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A8==" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text9").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A8==" check" && A9!=" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text9").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A9==" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text10").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A9==" check" && A10!=" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text10").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A10==" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text11").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A10==" check" && A11!=" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text11").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A11==" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text12").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A11==" check" && A12!=" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text12").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A12==" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text13").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A12==" check" && A13!=" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text13").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A13==" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text14").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A13==" check" && A14!=" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text14").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A14==" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text15").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A14==" check" && A15!=" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text15").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A15==" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text16").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A15==" check" && A16!=" check" && A17!=" check" && A18!=" check") this.getField("Text16").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A16==" check" && A17!=" check" && A18!=" check") this.getField("Text17").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A16==" check" && A17!=" check" && A18!=" check") this.getField("Text17").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A17==" check" && A18!=" check") this.getField("Text18").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A17==" check" && A18!=" check") this.getField("Text18").value=J1+", check ("+num1+")"+" "+al+" with info :"
if (num!=0 && A18==" check") this.getField("Text19").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
if (num==0 && A18==" check") this.getField("Text19").value=J1+", check ("+num1+")"+" "+al+" with info :"
Copy link to clipboard
Copied
Any help about new code?
Copy link to clipboard
Copied
You need to explain in words what you're trying to achieve and what are the exact rules behind it.
Copy link to clipboard
Copied
e.g.
i write a regular expression on text2 field if this is true then check if dropdown14.0 has check value and past to text1 the results
deferent if num1!=0 or num1=0
e.g.2
if i write on text3 filed system check if dropdown14.0 if dropdown14.1 has "check" value and put on text1 for drop down14.0 check or text2 for dropdown14.1 check. if dropdown14.0 if dropdown14.1 has same check value then put text to biggest (dropdown 14.1 => text2)
e.g.3
if regular expression on text4 is true
then
check dropdown list if check value and put right text results
14.0 >> check?
14.1 >>check?
14.2 >>check?
if
14.0 !=check
14.1 ==check
14.2 ==check
then put result on text3
e.g.4
if regular expression on text6 is true
then
check dropdown list if check value and put right text results
14.0 >> check?
14.1 >>check?
14.2 >>check?
14.3 >>check?
14.4 >>check?
14.5 >>check?
if
14.0 ==check
14.1 !=check
14.2 !=check
14.3 !=check
14.4 !=check
14.5 !=check
then put result on text1
Copy link to clipboard
Copied
You can use something like this:
var fld_name = "";
if (A18!=" check") {
if (A17!=" check") {
...
} else {
fld_name = "Text19";
}
} else {
fld_name = "Text19";
}
if (fld_name != "") {
if (num != 0) this.getField(fld_name).value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :";
else this.getField(fld_name).value=J1+", check ("+num1+")"+" "+al+" with info :";
}
Copy link to clipboard
Copied
Now you have changed the value to eliminate or filter out. Just change the filter to remove those values. If this value is default value, one could just compare the value of the field to the default value of the field and drop those values. If you accumulate the acceptable values into an an array, you can test if there are any values dropped by testing the length of the array, If it less than 500 then a field has not been completed.
Another approach would be set a variable to act as a flag. Setting the flag to true and then looping through the 500 field and if one has the value of the default value, set the flag to false and exit the loop. Now just test the value of the flag in you additional test.
Copy link to clipboard
Copied
gkaiseril because i use PDF expert to use this code on my mobile i think filter command isn't support by app... this is the list with support commands https://helpspot.readdle.com/pdfexpert6/index.php?pg=kb.page&id=1154
Copy link to clipboard
Copied
try67 i try to understand your code and change something commands but when i have 2 dropdown check how to add text on correct field?
var b = (num1!=0 && A0=="check");
var b1= (num1==0 && A0=="check");
if (b==true) {
for (var j=this.getField("Text68").value; j<=52; j++) {
var fz = this.getField("Dropdown14."+j);
if (fz.valueAsString=="check") {
this.getField("Text1").value=this.getField("Text1").value=J1+", check ("+num1+")"+" "+al+" with info :"
b=false;
break;
}
}
}
if (b1==true) {
for (var j=1; j<1; j++) {
var fz = this.getField("Dropdown14."+j);
if (fz.valueAsString=="check") {
this.getField("Text1").value=this.getField("Text1").value=J1+", check ("+num+")"+" "+hm+" "+"and"+" "+"("+num1+")"+" "+al+" with info :"
b1=false;
break;
}
}
}