• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Variable scope in scripts.

Variable scope in scripts. 14 years 1 week ago #10350

  • mware
  • mware's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
I'm wondering if there is any way to reference variables initialized in a script called on form display from within components. For instance, if I create a variable "$formatname" in a form display script, is there any way to retrieve that in a //<code> block in the default value for a field.

The reason I'm asking is I do a good deal of populating fields from community builder. I can populate these fields by scripting in the default value area, but that is wasteful as I need to repetitively execute a bunch of code for each field. It would be far more efficient to call the code once on form display, initialize all the variables I need, and then just grab those as the default values in the form.

I've tried various usages of the "global" declaration, but I haven't been able to find a way to reference variables from the on-display script. Calling all the code to get community builder fields once or twice within a form isn't so bad, but calling it 25 or more times is excessive.

Thanks!
The administrator has disabled public write access.

Re:Variable scope in scripts. 14 years 1 week ago #10352

  • mware
  • mware's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Well ... I figured out that I can use str_replace to replace the value= tag in the HTML by setting something identifiable (ex: %firstname%) to replace.

A more elegant solution would be nice, however. I'm hoping I'm just overlooking something.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!