Expand my Community achievements bar.

Refer to multiple objects with 1 variable

Avatar

Level 4

In general, how would one do that?

In an object, I can declare a variable to be another object, but really I want to access multiple rawValues. 

So if I have 2 fields, I'd like to have something like:

var A = textfield1 ||

           textfield2;

          ..............

 

if (A.rawValue == null) {

do something;

}

In this example, there's no need to even use variables of course, but if I want to reference 200 fields, there has to be an efficient way of doing it (related to another question I asked about required fields).   Any ideas?  Variables are new to me-I've used some Form Variables, but I've set them equal to hard-coded numbers.

Thanks!

1 Reply

Avatar

Level 10

Hi,

In relation to Form Variables, which are initially set in the File > Form Properties > Variables. You can set the value of the Form Variable (and get it) using the .value. So for example if the Form Variable was called myVariable, the following would apply:

myVariable.value = 10; // Sets the variable

app.alert(myVariable.value); // Would pop a message with 10

That's not the issue here. I think the best route would be to put the 200 fields into a container/subform and then have script loop through the contents of the container/subform. Paul Guerette's LockAllFields is a great example of such a loop. There is an amended version of it here: http://assure.ly/yDtfsM.

That cn be adapted to do anything with the objects, so it depends on what action you are after.

Hope that helps,

Niall