Passing variables between forms/fields

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

robdoddy
Ebase User
Posts: 3
Joined: Mon Jan 09, 2012 6:36 pm

Passing variables between forms/fields

#1

Postby robdoddy » Fri Mar 02, 2012 3:01 pm

Hi Guys,
Apologies if this sounds like a stupid question, I am still learning my way around Ebase and its foibles! Is there a way to store variables between form pages, in a kind of global-variable way? Or just by passing the variable to a form field from one form to another?

For example, I have created a basic login form and a script in Ebase that does a lookup in a database table for the username and password, and if they both exist, opens the next form. Is there any way that I can take the user-entered username value and apply it to a text box on the NEXT form to be loaded, or store it as a variable somewhere that I can then use to do further database work with once the user has proceeded past the login form? As far as I can see, as soon as the next form is loaded, the current script is ended, so I can't do something like:
goto FORM FRM_2;
set FIELD1 = un; (if 'un' is the username variable in the current form)

I know this sounds like such a stupid question, apologies it is my first foray into coding in FPL and Ebase. Thanks in advance for any help :)
0 x

Hovik
Moderator
Moderator
Posts: 184
Joined: Tue Sep 11, 2007 8:58 am

#2

Postby Hovik » Fri Mar 02, 2012 5:01 pm

You have 2 options:

Option 1
In the 2nd form, you check the 'URL parameter' checkbox for any field which will be passed into that form (say UN). The 1st form then does something like:

Code: Select all

goto form FRM_2 UN=FORM1_UN;  // what's on the right hand must be a field in the 1st form
As the 2nd form starts, UN will be set to FORM1_UN from the 1st form.

Option 2
The 1st form uses function setsessionvariable to store the username within the browser session, e.g.

Code: Select all

STATUS = setsessionvariable('UN', FORM1_UN);  // STATUS is a char field - will be set to 'OK'
The 2nd form uses function getsessionvariable to extract the username from the browser session, e.g.

Code: Select all

FORM2_UN = getsessionvariable('UN');
I've used FORM1_UN, FORM2_UN for clarity. No reason why you can't use UN in both forms - there'll be no confusion.

See the online documentation for more details. Search getsessionvariable and you'll find it.

I hope this helps.
0 x

robdoddy
Ebase User
Posts: 3
Joined: Mon Jan 09, 2012 6:36 pm

#3

Postby robdoddy » Mon Mar 05, 2012 9:32 pm

Hovik you are a star, thank you so much :D Thats exactly what I needed, just tried both ways and it works perfectly! Thanks again.
0 x


Who is online

Users browsing this forum: No registered users and 112 guests