Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How do I use javascript or formcalc to reference child controls (not by name)

Avatar

Avatar
Validate 1
Level 2
past-tense
Level 2

Likes

9 likes

Total Posts

85 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
past-tense
Level 2

Likes

9 likes

Total Posts

85 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
past-tense
Level 2

15-08-2012

Hi everyone,

I've created a ton of reports in the past, and I'm now looking at creating some reusable objects so that other people can use advanced form functionality without having to learn to use scripts.

A lot of the coding was acheived using this, .parent, etc. so that they can rename controls and subforms without having to worry about breaking scripts. One issue that I am having is that Some of my code looks at children controls, and references them by name (for example, I have some code that uses setfocus to move the user to the first field in a subform).

In most languages, there are ways to refer to child controls via an indexer or an items/children array. i.e. Subform.items[0].rawValue.

I know that this would pose some issues, but I think I could sort it out, if only I knew where to start. Is there some way to reference a child control without it's name?

Thanks for your help!

- Scott

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

269 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

269 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

16-08-2012

Hi Scott,

The subform has a nodes collection you can loop though, as you suspected.  If might show up more than you want but you can test the className to see if it is a field and then ui.oneOfChild.className to work out what type of field. So;

for (var i = 0; i < Subform1.nodes.length; i++)

{

    var n = Subform1.nodes.item(i);

    console.println(n.className + " " + n.name + " " + n.ui.oneOfChild.className);

}

Hope this helps.

Bruce

Answers (0)