


Hello all,
New to LS and JS.
I have a form where the user is able to click a plus button to duplicate a portion of a subform. There is a text label inside that subform which needs to get it's string value from a textfield located elsewhere in the parent form. I can get the parent text field to populate the first text label (child) by using the "this.rawValue" in the parent text field. But when new subforms (children) are created using the + button, the text label located in the new children subforms initialize with the original text label name.
Using JS, how might I have these new children text labels initialize using the string value found in the parent text field?
I hope this can be answered without submitting an example, because this form would require a lot of redacting to make that possible.
Thanks,
Graham
Views
Replies
Sign in to like this content
Total Likes
OK, I figured out that a function call would do the trick, but now there is a new issue:
To summerize, here is what works:
The user inputs "textString" into topLevel text field. -> Upon initialization of instance, function call places "textString" in childLevel text label.
Now, the problem:
If the user changes the topLevel text field "textString" value AFTER the instance has been created, the instanced childLevel text label does not get updated to reflect that change. How might I get the topLevel text field to update the instanced childLevel text label after it has been created?
Thanks!
Graham
Views
Replies
Sign in to like this content
Total Likes
Hi,
I think you are trying to alter the caption value of a textfield in a repeating subform/table.
You could try the following in its calculate event:
this.caption.value.#text = topLevelTextfield.rawValue;
You may want an if statement to deal with situations when the topLevelTextfield value is null.
Hope that helps,
Niall
Views
Replies
Sign in to like this content
Total Likes
Hi Graham,
I have some suggestions to your problem.
In the exit event of the text field, call a function. The function would do the following;
1) Loops through all the nodes of the subform
2) Retrieves the value of the text field and assigns it to the text(as per your requirement)
Hope this will work.
Views
Replies
Sign in to like this content
Total Likes
Niall,
I understand what you're saying, but how would you go about adding a script to the calculate event... textfields don't allow scripting, or do they in some way? All the events are greyed out when the textField is selected.
Graham
Views
Replies
Sign in to like this content
Total Likes
I think you're thinking of a Text object, not a Text Field. A Text Field will be outlined in orange in the Design View, while a Text object will be outlined in blue. If you're using a Text object, then you can't write scripts on it, but you can alter it by scripts. Otherwise, you can just use a Text Field with no caption (or a caption if you need it, I guess) and make it readOnly or Protected in the Value tab of the Object palette. You can write whatever scripts you want on a Text Field. Does that make sense?
Views
Replies
Total Likes
Thanks AJP for clarifying. Of course you are correct. I meant Text Object. I think I have gotten the scripitng down for changing the Text Object, I'm just having trouble altering text for instances not yet created. But that's another thread I suppose.
Graham
Views
Replies
Sign in to like this content
Total Likes
Hi graham,
AJP256 is right, just drag a "Text Field" onto the form instead of a "Text" object.
You can script a Text Field to change its value and appearance.
When designing the form you can set the caption and borders of the Text Field to none, so that it looks like standard text. The text that is displayed can then be changed depending on users' input/actions.
Hope that helps,
N.
Views
Replies
Sign in to like this content
Total Likes
Hi Graham,
Instead of pushing the value from the parent to the child object (repeating instances), why not get each child objects to look back to the main object.
This would be a calculate event script in the repeating subform/table object:
this.rawValue = topLevelTextfield.rawValue;
Just a thought...
N.
Views
Replies
Sign in to like this content
Total Likes
Thank you all for your help.
Yes, Niall, your suggestion worked. It worked beautifully.
Graham
Views
Replies
Sign in to like this content
Total Likes