Skip to main content
Inspiring
November 18, 2018
Answered

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

  • November 18, 2018
  • 4 replies
  • 939 views

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

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer try67

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

4 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 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.

hackertomAuthor
Inspiring
November 18, 2018

@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?

try67
Community Expert
Community Expert
November 18, 2018

You should add the full code in the other thread.