Contents
Retrieve Values From the Same Page
It is possible to get the value from an element outside of the actual form. In order to do this, we need an input element with an individual selector like an ID or a class:
<input id="coffee" class="class-coffee" type="text" value="100" />
The input field’s ID is coffee, so the selector can be:
#coffee
or
.class-coffee
Please keep in mind that if there are multiple elements with the same selector, the plugin may not be able to retrieve the correct value. Read more about CSS selectors on MDN web docs.
Next, open up the element in the form editor, look for the option called Value_external and enter the selector there. If you want the element to listen to any changes on the target selector, set the option Value_external_listen to Yes.
Example
Input field (#coffee)
Form
Retrieve Values from GET Parameters
With ez Form Calculator, you can also retrieve values from a URL parameter. Example:
http://yoururl.com/page?id=123
In order to retrieve the value of the id-parameter, open up the element in the form editor, look for the option called GET and enter the relevant parameter there (id in this case).
Retrieve value from an external URL
If your web server supports cURL or allow_url_fopen is enabled, you can get the value of an external page to be included in the form. Let’s say the URL you want to retrieve the value from returns a number or a string. Find the element option Value_http and simply enter the URL there.
The plugin is also able to parse a JSON request. Example URL: https://www.bitstamp.net/api/v2/ticker/btcusd/
When you open the URL, you will see a string in the JSON data format. The element option Value_http_json parses the returned JSON string and you are able to select any key within. If the JSON string contains multiple objects, you can access an object’s key via a dot, e.g.: myobject.key.anotherkey