Retrieve dynamic form variable names with SolutionModel

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Retrieve dynamic form variable names with SolutionModel

Postby vincentSchuurhof » Thu Aug 05, 2010 12:32 pm

I'm changing an existing form and adding form variables with the SolutionModel like this:

Code: Select all
var form = solutionModel.getForm('form_name');
for (var i = 0; i < numberOfVariables; i++) {
   var variable = form.newFormVariable('formVariable' + i, JSVariable.TEXT)
   variable.defaultValue = '"value"';
   var field = form.newField(variable, JSField.TEXT_FIELD, 0 ,0, 100, 20);
}


Then after the user changes the value of these form variables, I want to retrieve them. Now I want to display all their values and so I use a loop:

Code: Select all
for (var i = 0; i < numberOfVariables; i++) {
   application.output(forms['form_name'].formVariable;
}


Now, with what should I replace the last 'formVariable' to make sure I retrieve values for 'formVariable1', formVariable2', formVariable3' and so on? It's not an array, so '[i]' isn't working and neither is '+i'.

I think I'm missing some trick here. Does anyone have an idea?
vincentSchuurhof
 
Posts: 26
Joined: Fri Aug 21, 2009 12:39 pm

Re: Retrieve dynamic form variable names with SolutionModel

Postby mboegem » Thu Aug 05, 2010 12:40 pm

vincentSchuurhof wrote:application.output(forms['form_name'].formVariable


forms[form_name]['formVariable' + i] should do the job

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1749
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Retrieve dynamic form variable names with SolutionModel

Postby vincentSchuurhof » Thu Aug 05, 2010 1:20 pm

Thanks Marc, that helped indeed! :-)
vincentSchuurhof
 
Posts: 26
Joined: Fri Aug 21, 2009 12:39 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 8 guests