MarcoTenzer
Posts: 0
Joined: Fri Jul 29, 2011 5:12 pm

Reading values from input fields

Having 2 input fields and 1 button, how can i add 2 given numbers and show the result when the user clicks on the button ? The point is, I have no clue how to read those 2 values from the input fields. Could anybody please give me a hint ?

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

Reading values from input fields

To read values from input fields, you can define a variable via events (see screen shot, I used 'onload' event). But the problem is, there is no way right now to write a JavaScript function to add those two numbers.

Image

MarcoTenzer
Posts: 0
Joined: Fri Jul 29, 2011 5:12 pm

Reading values from input fields

Thanks for your help, Max. So my next question would be: when will it be possible to add such a javascript function ? ;-)

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

Reading values from input fields

To be honest, I don't have a time frame for this feature yet. But, please create a new issue and set it as Idea so you can track its progress.

Danny
Posts: 0
Joined: Tue Nov 15, 2011 10:51 am

Reading values from input fields

So, if I want to send the user to a webpage, and have the URL contain some variables from storage, it cannot be done? For instance, create a google search?

If still not available, was this created as idea? I would like to vote.

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

Reading values from input fields

You can do it. In service mapping, you can read values from local storage. Here is an example:

Image

To save a value to local storage, you can use Set Local Storage Variable action.

Hope this helps!

Danny
Posts: 0
Joined: Tue Nov 15, 2011 10:51 am

Reading values from input fields

Thanks Max, will try and edit this post if failed.

Edit:
Ok, I am still lost....

For the sake of simplicity, lets just say I want to do a Google search (input+button) that will open the result in a browser.

Created input, called it "query"
Created Rest service, with the Google URL, and with the "q" parameter.
Mapped the "q" parameter to the "query" input field.
Created a button that invokes the service.
Now, I cannot figure out how to make this service open a webpage.

P.S.
I thought services are NOT intended to be used like this, but rather be web services to fetch data from RESTful APIs.
I thought I should use the simple event action "Open a Link" or Run Custom Javascript to do this.

What am I missing?

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

Reading values from input fields

I'm not sure that will work, I tried https://www.google.com/?q=test but it didn't work, it wants me to click on Search button. Google does have search REST API, so you probably want to use that.

Danny
Posts: 0
Joined: Tue Nov 15, 2011 10:51 am

Reading values from input fields

Thanks Max,

The proper way to call a google search result page is
https://www.google.com/search?q=test

But in any case, this was only an example to demonstrate what I want to do, which is:

  1. Grab parameters from either an input field, or a local store

  2. On a button click, open a web page using a URL that uses these parameters.

    For my need, imagine that the user enters his age and gender, and clicks "Go" and I open a page on my website that uses this data.

    This, in my opinion is a basic functionality that must be available.
    I am surprised that on one hand you have such nice and deep functionality, such as the entire REST service handlers, and on the other hand, storage variables and form fields cannot be accessed by most features.

    For instance, if these variables would have been accessible to a custom javascript, and the custom javascript could use a command to invoke the web browser on a specific page, this functionality could have been available.

    Another approach I was thinking about, is to make the "Open a Link" action accept inline arguments, so for example I could use:
    http : / / google.com/search?q=[NameOfInputField.text]

    as a generic syntax to access attributes from other places of the application.

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

Reading values from input fields

Got it, here is how to do it:

Check out this app: http://gotiggr.com/preview/21674/.

The input field is named 'search'.
The button has custom JavaScript that looks like this:
code
var s = Tiggr('search');

window.open('https://www.google.com/search?q='+s.val(), 'NewWindow', 'width=600,height=400,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
/code

Return to “Issues”