Using Web Forms to return data based...

User 2375218 Photo


Registered User
6 posts

Is there a way to return calculated data based on the input from a form? Specifically, I'm trying to use a form as a BMR (Basal Metabolic Rate) Calculator. Essentially, I will have users put in their sex, height, weight, age, and activity level and I will calculate their BMR and average caloric expenditure from that, but I can't figure out how to do it using this utility. Is this possible?

Thanks in advance.

Justin
User 38401 Photo


Senior Advisor
10,951 posts

Hiya Justin,

This is only possible if you use other scripts to do the calculations for you as the Form Builder doesn't have any type of calculation features at this point. It has been suggested a few times so we're hoping it will be in a future release, but for now you'll need to do some integration with other systems to accomplish what you need.
User 2375218 Photo


Registered User
6 posts

Jo Ann,
I don't suppose you have any examples of this in action or know where I can find some? The calculations themselves are very simple...I judt don't know how to integrate it.

Thank you :)

Justin
User 38401 Photo


Senior Advisor
10,951 posts

no unfortunately I don't Justin, I just know you need more than the Form Builder to do it. There may be others that have some ideas though. I'm not a programmer so I try to keep things simple lol, but there's a few that are pretty good with programming things so they may have some good ideas :)
User 2073552 Photo


Registered User
1,625 posts

Justin,

Try this and see if it would work for your situation...

http://www.javascript-coder.com/javascr … ript.phtml
"An Apple doth not fall far from its tree, yet an orange does."

https://lbwebsitedesign.com - Responsive Web Design & Web Hosting Services.
http://helpsite.sirage.com - HTML5, CSS3 and CC Help Video Blog.
User 2375218 Photo


Registered User
6 posts

SirAGE,
I looked at that and it seems like it will do what I want. The only difference is I will have to have an IF condition somewhere (the calculations are different for Males and Females). I'll work on it tonight. Thanks!

J
User 2073552 Photo


Registered User
1,625 posts

Anytime! Glad we could help!
"An Apple doth not fall far from its tree, yet an orange does."

https://lbwebsitedesign.com - Responsive Web Design & Web Hosting Services.
http://helpsite.sirage.com - HTML5, CSS3 and CC Help Video Blog.
User 464893 Photo


Ambassador
1,611 posts

Justin give me a link to your csv file. Also the calculations that give the result. I will have a look at it.
It can be done.
You will have to modify the form settings to redirect to a script. I will fit it in over the next week. Rather busy I am afraid just come in from gardening and having a rest.
send details via http://inkmon.org/contact.html
The link is necessary to tell the script where to find the data entered into the form. The script will do the calculation on the last entry and display the result in a seperate page. I cannot re populate a WFB form it does not have that ability but return from the display to the form for another entry is possible.
The Guy from OZ


User 957373 Photo


Registered User
8 posts

I would love to use this software to make a time sheet, but I don't see a way to have it total up the hours at the bottom. I just bought a book on javascript though - looks like that will probably be the best way to proceed for now.

I would like to know if there is any way to integrate my own javascript into an existing formbuilder form?
User 464893 Photo


Ambassador
1,611 posts

As it is server side I would suggest you look at php. not any harder than JavaScript but you can access data straight from the form. JavaScript is Client side Php is Serverside. The data that WFB delivers is on the server. If you create your form manually say with CC's HTML editor then you can Post or Get in JavaScript.
This is a simple script to read a csv file. To do what you want is just a step away

<?php
error_reporting(E_ALL & ~E_NOTICE);
$file_handle = fopen("http://mysite.com/Decision/storage/csv/results.csv", "r");// the address where the file is located
while (!feof($file_handle)){// this loops through the file and gets the last entry received
$item = fgetcsv($file_handle, 1024);
if($item=="")Break;// make sure the last entry is used
$lastitem=$item;
}
fclose($file_handle);
$option= $lastitem[0]; //The number in brackets is the position in the csv file where the data is
?>


Now from there you gather the results into variables ie:-
$Option[0]; first
$Option[1]; second
$Option[10]; any order
Calc
$result =$Option[0]+$Option[1]+$Option[10]; // simple addition

You wont break anything by trying the code.
This script is triggered by a form Submit with the settings including a redirect to the script file.

I have a couple of examples of what is possible. http://phpsnippets.webatu.com/

I can help if you get stuck but it wont get done itself. Plenty of examples online, plus there are php forums where the members will help. It is out of the range of this forum. I will defiantly help you, but you will have to do it yourself. It is not that hard.
The Guy from OZ



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.