Jonathan Clark
Posts: 0
Joined: Thu Mar 14, 2013 5:25 pm

Passing multiple values to a single label

I'm trying to figure out how to take the value from two different fields, perform calculations on them and then return the value of those calculations. I have a response that returns an array of fields. Two of the fields contain location cordinates (one field for lat, one field for long).

What I want is to pass both of these values to a single label element, run them through a function that gets a saved set of coordinates from local storage, and the returns the distance between the two sets. I have a working function to perform the calculations but I just can't figure out how to access the values when passing two fields to a page element. Any advice?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Passing multiple values to a single label

I hope I understand the question correctly, but you can read values from a Label component using:

code
Tiggzi('component_name').text();
/code

More info on JS API http://docs.tiggzi.com/javascript-api/

Jonathan Clark
Posts: 0
Joined: Thu Mar 14, 2013 5:25 pm

Passing multiple values to a single label

I suppose that does help a little and I think for what I am trying to accomplish I could add two additional labels that are not visible to just hold the value momentarily.

Just to clarify on my original question:

I receive a response from the DB that is an array of records, and there are two specific fields in each array that I want to use in a function that then produces the value that I want to display on the page. I don't really want either of the two values from the response to be displayed. (The two values are lat,long cords that I then want to run through a function that calculates the distance between the returned lat,long and the users lat,long)

As I'm typing this, It's just occurred to me that maybe I should re-format the response so that each record array contains another array which contains the lat and long fields, and then pass that actual inner array ($) to the label?
Would that then pass the array to the javascript function as the value variable?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Passing multiple values to a single label

Hello! You can redefine the response, but from Label it won't be passed as an array, but as the string. If this string is a correct json object then you can parse it using JSON.parse

Return to “Issues”