Locked

[LOCKED] if loop with many parameters how to write smarter code there?

Explorer ,
Nov 18, 2018

Copy link to clipboard

Copied

i have 52 lines, and 52 text fields with some parameters.. and understand the code is not manageable... (so many writes) it is possible for a smarter solution ? if i use arrays? something else?

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

TOPICS
Acrobat SDK and JavaScript

Views

167

Likes

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

1 Correct Answer

Most Valuable Participant , Nov 18, 2018
try67 Most Valuable Participant , Nov 18, 2018
You already got answers in your other thread (if loop with many parameters (&& * 500) ). Please don't post the same question multiple times.

Likes

Translate

Translate
Jump to answer Jump to answer
Most Valuable Participant ,
Nov 18, 2018

Copy link to clipboard

Copied

You already got answers in your other thread (if loop with many parameters (&& * 500) ). Please don't post the same question multiple times.

Likes

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
Explorer ,
Nov 18, 2018

Copy link to clipboard

Copied

@try67 I add full code now and not example I think this is not the same code e.g. Text fields and others... Text field must write by me? Text1..Text2 or it's better with array?

Likes

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
Most Valuable Participant ,
Nov 18, 2018

Copy link to clipboard

Copied

You should add the full code in the other thread.

Likes

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
hackertom AUTHOR LATEST
Explorer ,
Nov 18, 2018

Copy link to clipboard

Copied

ok i move the code to previous thread, please a mod to delete this thread and sorry to open this... 😕

Likes

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