Skip navigation
Currently Being Moderated

Getting value of a variable in another script object

Jul 23, 2012 9:16 AM

Hi all,

 

I have a scenario where I have one script object (MyTexts1) containing a lot of text for the form (each of the texts are stored in variables (fx. MyTexts1.infoText1). The variables are named after the fields (meaning that I have a field called "infoText1").

 

So for each field I call a function that takes the name of the field. This function (located in my script object called "functions") should somehow then find the value of the variable in "MyTexts.infoText1".

 

Now my question is:

 

How can I achieve the above scenario - and if not why?

 

Thanks in advance

 

 

Cheers

Kim Christensen

Dafolo A/S

Denmark

 
Replies
  • Currently Being Moderated
    Jul 23, 2012 10:29 AM   in reply to kc@dafolo.dk

    Hi,

     

    I can't follow you description.

     

    You have a script object "functions" right?!

    In this script object you have declared variables, but how?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 23, 2012 12:40 PM   in reply to kc@dafolo.dk

    Hi,

     

    you can do this with just one script object.

     

    For example the "MyTexts" script object with the string variables and a function to return the values.

     

    var infotext1 = "Lorem ipsum dolor sit amet"
    var infotext2 = "Non eram nescius Brute cum"
     
    function getText(FieldNumber) {
              return eval("infotext" + FieldNumber);
    }
    

     

     

    To populate a field you can call the function in the script object with an argument, which is the alias for the varaible number you want to return.

    You don't need to enter the full somExpression to your script object, the name is enough.

     

    Textfeld1.rawValue = MyTexts.getText(1);
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points