Copy link to clipboard
Copied
it is possible to write something like this and work?
var fields = ["Dropdown14.0","Dropdown14.1","Dropdown14.2"];
var fields1 = ["Text1","Text2","Text3"];
for (var i in fields && i1 in fields1)
{
var f = this.getField(fields);
var f1 = this.getField(fields1[i1]);
if (f.valueAsString!=1==false && f1.valueAsString!=2==false) total++;
}
i now the syntax "for in" check only one table at the time... it is possible to check 2? because now this not work...
You can do it like this:
for (var i=0; i<fields.length; i++) {
var f = this.getField(fields);
var f1 = this.getField(fields1);
if ( ... ) total++;
}
Of course, the length of the two arrays has to be the same for it to work.
PS. Your if-condition is incorrect I so removed it from the code.
What exactly are you trying to check?
Copy link to clipboard
Copied
What want you count?
Copy link to clipboard
Copied
You can do it like this:
for (var i=0; i<fields.length; i++) {
var f = this.getField(fields);
var f1 = this.getField(fields1);
if ( ... ) total++;
}
Of course, the length of the two arrays has to be the same for it to work.
PS. Your if-condition is incorrect I so removed it from the code.
What exactly are you trying to check?
Copy link to clipboard
Copied
my thought is when only
"Dropdown14.0" is 1 and "Text1" is 2 then total++
"Dropdown14.1" is 1 and "Text2" is 2 then total++
"Dropdown14.2" is 1 and "Text3" is 2 then total++
but when e.g.:
"Dropdown14.0" is 1 and "Text2" is 2 then NO COUNT
or "Dropdown14.1" is 1 and "Text1" is 2 then NO COUNT
or "Dropdown14.2" is 1 and "Text3" is 2 then NO COUNT
or "Dropdown14.1" is 1 and "Text3" is 2 then NO COUNT
or "Dropdown14.0" is 1 and "Text2" is 2 then NO COUNT
.
.
.
Copy link to clipboard
Copied
The first two conditions are contradictory.
Copy link to clipboard
Copied
What do you mean? Its not possible to create this?
Copy link to clipboard
Copied
It's logically contradictory:
"Dropdown14.0" is 1 and "Text1" is 2 then total++
"Dropdown14.0" is 1 and "Text2" is 2 then NO COUNT
Copy link to clipboard
Copied
yes you has right, my mistake remove this "Dropdown14.0" is 1 and "Text2" is 2 then NO COUNT
I wrote some possible examples..
this examples is count++ only if one is deferent then NO COUNT :
"Dropdown14.0" is 1 and "Text1" is 2 then total++
"Dropdown14.1" is 1 and "Text2" is 2 then total++
"Dropdown14.2" is 1 and "Text3" is 2 then total++
and I have another question, if i replace 2 with regular expression how to write on code? this is correct?
var fields = ["Dropdown14.0","Dropdown14.1","Dropdown14.2"];
var fields1 = ["Text1","Text2","Text3"];
var myRegExpadt = /^.*?(\B[A-Z.]{1,2}[0-9]{6}\b).*NAME:\ [A-Z]+.*$/;
for (var i=0; i<fields.length; i++) {
var f = this.getField(fields);
var f1 = this.getField(fields1);
if (f.valueAsString!="1"==false && myRegExpadt.test(f1.valueAsString)==false) total++;
}
Copy link to clipboard
Copied
I don't understand why you're trying to use a RegExp for... It's better to walk before starting to run.
Your condition can be:
if (f.valueAsString=="1" && f1.valueAsString=="2") total++;
Copy link to clipboard
Copied
i try this code and work, but has a problem : first Text field must have 2 and then dropdown list number 1 to count total++
if i choose first dropdown list number 1 and them write on text field 2 then no count...
My RegEx help me to check a code : \B[A-Z.]{1,2}[0-9]{6}\b and a name :.*NAME:\ [A-Z]+.*$
if this is true and dropdown list is 1 then only count, i replace RegEx with 2 for more easy example...
this is correct?
if (f.valueAsString=="1" && myRegExpadt.test(f1.valueAsString)==true) total++;
Copy link to clipboard
Copied
You can't really explain a rule by examples. Please explain the actual rule you want. If you can't, keep working on it. This is a common problem many programmers hit: trying to program (which is exact) for something not fully understood or planned. Just can't be done.
Copy link to clipboard
Copied
it is possible to read table positions with for loop? e.g. position 1 on table fields is "Dropdown14.0" how can i read only this?
Copy link to clipboard
Copied
If you only want one element, just don't use a loop.
Copy link to clipboard
Copied
i want to check all 6 cells
"Dropdown14.0" --> "Text1"
"Dropdown14.1" --> "Text2"
"Dropdown14.1" --> "Text3"
now I thought if loop check cell position 1 for fields=1 & fields1=2 then totall++
var f = this.getField(fields.rows[0].cells.length);
var f1 = this.getField(fields1.rows[0].cells.length);
and if I work I'm going to the other below.... this is error;
Copy link to clipboard
Copied
The code I provided will do that. You can't just invent syntax and hope it to work.
Copy link to clipboard
Copied
correct answer try67 now i understand your code...