Skip to main content
Known Participant
January 3, 2021
Answered

Need help with fields in var

  • January 3, 2021
  • 3 replies
  • 883 views

How do i put more fields in one variable?

I tried this but it's not working

var fields = ["Text1","Text2","Text3"];
fields.value = event.value;

This topic has been closed for replies.
Correct answer try67

You need to use a loop, like this:

var fields = ["Text1","Text2","Text3"];

for (var i in fields) this.getField(fields[i]).value = event.value;

3 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 3, 2021

You need to use a loop, like this:

var fields = ["Text1","Text2","Text3"];

for (var i in fields) this.getField(fields[i]).value = event.value;

kiki1986Author
Known Participant
January 3, 2021

Thank you, thats what i was looking for.

Legend
January 3, 2021

You know how to set just one field value, right? With just one field name? So, write it out 3 times, with the 3 different field names, instead of trying any tricks to set all 3 in one line.

Legend
January 3, 2021

To set three fields you must set each value in turn. 

kiki1986Author
Known Participant
January 3, 2021

Can you pls explain what you mean?