Send parameters to a javascript function ?

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

armin_kessler
Ebase User
Posts: 27
Joined: Sun Jan 08, 2012 2:39 am

Send parameters to a javascript function ?

#1

Postby armin_kessler » Fri May 11, 2012 4:32 pm

It's possible to send parameters to a function
in javascript function for processing in a
Jquery widget, for example records in a table
to a javascript array.

Thanks Armin
0 x
Armin Kessler

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#2

Postby Wai » Mon Dec 17, 2012 3:35 pm

Yes it is, are you looking for a way to do this still?
0 x

armin_kessler
Ebase User
Posts: 27
Joined: Sun Jan 08, 2012 2:39 am

Send parameters to a javascript ...

#3

Postby armin_kessler » Fri Dec 28, 2012 12:39 am

Yes, if this is possible could you send me examples or
where to find it.

Thanks Armin
0 x
Armin Kessler

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#4

Postby Wai » Tue Jan 01, 2013 4:23 pm

You can do this by looping through your table and adding the values into a Ebase Form field (e.g: mydata), for example a comma separated list of values.

You can then use field substitution notation &&mydata to substitutte the list of values into a JS variable or array.

There is an example of this on the Ebase website with using JPlot for plotting graphs where the data is in an Ebase table.

See Resource Centre - UI Library - Graphing

The following line in the example:

Code: Select all

s1 = [ ['Car',250],['House',600],['Bills',720],['Loans',385],['Entertainment',150],['Sundry',200] ];
would become

Code: Select all

s1 = &&mydata
you therefore have to construct the string in FPL including the '['
0 x

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#5

Postby Wai » Tue Jan 01, 2013 4:26 pm

You can also get the value of form fields using JQuery selectors such as

Code: Select all

$('#mydata').val()
where mydata is the ID of your field control. See HTML Element Properties.
Last edited by Wai on Mon Mar 04, 2013 2:15 pm, edited 1 time in total.
0 x

armin_kessler
Ebase User
Posts: 27
Joined: Sun Jan 08, 2012 2:39 am

#6

Postby armin_kessler » Thu Jan 03, 2013 3:21 am

Wai:
Thank you very much for your attention, and I hope you the best for this year 2013.
You can do this by looping through your table and adding the values into a Ebase Form field (e.g: mydata), for example a comma separated list of values.
I don't understand quote , could you ilustrate this with an example or where to find it.

Thanks Armin
0 x
Armin Kessler

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#7

Postby Wai » Thu Jan 03, 2013 9:04 am

For example, the JPLOT JQuery graph plugin requires the following to render a pie chart:

[label,value],[label,value],[label,value]...etc

You can build this in FPL (or javascript in 4.4) with values in your table.

For example to plot sales percentages of products we'll pass something like this below, where the label is a table column (mydata-product) and value is a table column (mydata-sales):

['Twix', 19.63],['Snickers', 7.47],['Paprika', 6.12],['Others', 66.78]

In our script we can build this as a string into an Ebase field (data):

Code: Select all

set data = null

loop at table mydata

   set data = '[\'' + mydata-product + '\',' + mydata-sales + '],';

endloop

// Removing the trailing comma:
set data = substring(data,1,length(data) - 1);
Hope that helps.
0 x


Who is online

Users browsing this forum: No registered users and 11 guests