Need help with javascript
Can someone help me make these codes into one code?
I have ten fields named t1-t10,
in each field as custom calculation script I have these codes
in field1:
event.target.fillColor = this.getField("Text1").value >= 1 ? color.green : color.white;
in field2:
event.target.fillColor = this.getField("Text1").value >= 2 ? color.green : color.white;
in field3:
event.target.fillColor = this.getField("Text1").value >= 3 ? color.green : color.white;
...etc up to field 10:
event.target.fillColor = this.getField("Text1").value == 10 ? color.green : color.white;
I want to put them in one field and have as one code, I know how to make them like this:
event.target.fillColor = this.getField("Text1").value >= 1 ? color.green : color.white;
this.getField("t2").fillColor = this.getField("Text1").value >= 2 ? color.green : color.white;
...etc but I was wondering can it be done as one code something like:
var color = "";
for (var i=1; i<=10; i++) {
if (this.getField("t1"+i).value=="1") color++;
}
event.target.fillColor ? color.green : color.white;
Of course that doesn't work but you get idea what I'm looking for.
