Can this program do calculations? -...

User 551681 Photo


Registered User
2 posts

Is there a way of getting calculations working on a form? I need to create a booking form that adds up a total interactively. i.e. as the form is being filled in and options are selected there is a totaliser field that gets updated so my clients can see what they are spending. (see http://www.tictocplay.com/clubs/holiday/index.html for reference)
PS thanks for the great HTML builder and FTP software.
Cheers
Richard
User 238931 Photo


Ambassador
1 post

the same question for that i'm looking the answers. did you get a hint?
User 2307824 Photo


Registered User
52 posts

I believe there a few of us wanting this ability. At the moment, i believe CC have it on their to-do list. Otherwise you may have to learn to use PHP and then learn how to add the scripting in to the forms code.
I had setup a form once in a piece of MS software but it only works in-house thru sharepoint so its no good for websites.

It is a feature that i would use in a heart beat or maybe 2 beats at the speed of my heart..lol.. if it was able in cc wfb
User 187934 Photo


Senior Advisor
20,181 posts

I bet it could be done with a little JQuery and some adjustment to the HTML output. Otherwise wait and see what CC comes up with for payment integration.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 406086 Photo


Registered User
23 posts

I'll add my two cents... if CC would add calculations to the form builder I'd buy it in a heartbeat, talk my boss into it, and promote it to all my friends. It's the one feature I really need, and would use it this week on our new catalog if it were available.
User 474778 Photo


Registered User
215 posts

Dear Richard,

Dynamic problems, such as calculations, might be done on the Web server or on the browser. Complex problems might combine the two techniques and even run server- and client-side portions of the problem in parallel.

Happily, the problem you describe is not so complex. By "complex," I mean a problem that would require server-side database access in the midst of client-side user interaction. "AJAX" is a popular acronym for techniques that handle such problems.

Though the server-side approach (using PHP, for example) might be satisfactory for your stated problem, it's not a good idea. For a good user experience in the face of variable loading of your Web server and variable delays across the Web, it is much better to do form & calculation work on the client side, right there in the browser, using a language such as JavaScript (a.k.a. ECMAScript).

jQuery is a JavaScript library that is indeed relevant to your problem.

Coffee Cup is good at building tools that generatie client-side code that's easy to drop into a site. That and the HTML editor have been CC's bread & butter for years. However, designing a tool relevant to your problem that is general enough to be of wide interest, yet easy enough for non-programmers, is not so easily done. Everyone might be better off if you were to hire a programmer to do a bit of bespoke coding. Certainly your business can't be left hanging, waiting for Coffee Cup to perhaps develop the general capability.

Here are links to some background reading:

http://en.wikipedia.org/wiki/ECMAScript

http://en.wikipedia.org/wiki/AJAX_%28programming%29

http://en.wikipedia.org/wiki/JQuery

halfnium -AT- alum.mit.edu
Yes, I looked just like that in 1962.
User 464893 Photo


Ambassador
1,611 posts

Halfnium You are right to a point This WFB creates quality forms. When it comes to calculations that requires some form of expression to be invoked. As it stands the form accepts input and outputs notifications and will file results. In order to do a calculation a result needs to be manipulated. This requires external files.

I heard of a possible inclusion of a button with a regular expression. maybe this offers a way. It will still require some script to be that expression. I am waiting to see what transpires.

A form is designed to get information and any following calculation is limited to the data obtained from the form. Client side is your computer and programs on it manipulate data you can give or is present in some form. Server side scripts can only manipulate data that reside in files or a database. There can be a bit a interaction between the two but basically when one stops the other begins.

When you think about a calculation it is like saying how long is a bit of string. there are so many factors to consider, what data you have how is it to be manipulated and what is to be presented and in what form.

Can it be done Yes! will it be done in WFB I cannot see it. There are so many variations of calculations.
See what is allowed with a release of including a created expression. Then who knows.
The Guy from OZ


User 2307824 Photo


Registered User
52 posts

I believe there are many options for what has been discussed here. And all are valid options. Also as some have mentioned various forms of manipulations maybe required. However what I believe most are just looking for is a simple way to add some amounts together when an item is selected or not.

Mathematical equations where you try to solve the mysteries of the universe, would never be require for a product like this. After all we are talking about a basic form to collect some simple data. It is not a web shop. MS Infopath does it quite easily and effectively, however it really only works thru sharepoint on internal networks.

The issue from what I can see is the way CC WFB handles some of the form options, such as the dropdown boxes for example. Under WFB is seems to be you type your select option in to value box, instead of the amount or actual value. for instances here is some code
<form method="post">
<select name="Select1">
<option value="46">john</option>
<option value="89">brad</option>
</select></form>

as opposed to the CC code for a dropdown selection box

div class="fb-dropdown">
<select id="item6_select_1" name="NFA" data-hint="">
<option id="item6_0_option" value="None" selected>
None
</option>
<option id="item6_1_option" value="1 - 20 People $300">
1 - 20 People $300
</option>
<option id="item6_2_option" value="21 - 50 People $400">
21 - 50 People $400
</option>
<option id="item6_3_option" value="51 - 100 People $500">
51 - 100 People $500
</option>
As you can see there is nowhere in the last lot of code for an actual value. whereas the firt lot of code there is the value, which can then be utilised as needed. Unfortunately to make a change in CC WFB would remove the backwards compatibility to existing forms.

Now I could be wrong here, as I havent written any real code for more than 15-16 years so many things have changed. So I am definitely not an expert or anything even close, and certainly you guys and gals would have much more knowledge on this than me these days. To my way of thinking, as outdated as it probably is, to modify the cc code, would required a lot query type statements (if else, when elseif etc) to establish which option is selected and then assign an actual value to it, which could later be added to final value. I dont believe the math side of things would need to be complicated. However for CC to make a change like this could be a big problem. What do you all think ?
User 464893 Photo


Ambassador
1,611 posts

Jeff this is how I interpret what you have said

First a post action is stated something like

enctype="multipart/form-data" method="post" action="../action.php" novalidate="novalidate"
data-form="manual_iframe">

The option
option id="item6_3_option" value="51 - 100 People $500"> 51 - 100 People $500 </option>
the value in bold
After the submit button is pressed the information is passed to the file according to the post action now the way the information is passed by this statement
$Value=$_POST['Name'];
So in the option above the Value would be given 51 - 100 People $500"> 51 - 100 People $500
What would you do with that ?

In this form this is the value given (In Bold), it may not be in a form that would make calculations easy.
However if the information to be calculated was always in that form then it could be analysed after sorting according to what the data is reporting. It could be treated as a string and the information stripped off and re written. This would require a special script. Can it be done Yes! by any form builder Definatly not.

Think of a Spreadsheet. It has the tools to calculate the data in columns which is precisely how those values are stored. The Name is the field or column name and the Value is the data in that field.

Would you expect a form builder to have the afterburner of a spreadsheet. I am afraid that would require processing after WFB or any other form building method has wiped its hands of its output.
The Guy from OZ


User 464893 Photo


Ambassador
1,611 posts

I have come back as I did not want to make a negative post. If anyone wants to do some form of calculation of data entered into a form I am prepared to work with them to achieve a solution.

I have said before its one of my hobbies. I am considering using WFB to demonstrate various ways to use data obtained from a form. I am working on something for myself. I will share when finished.

One example I have made is here http://inkmon.org/Test/index.html It demonstrates what can be done with data after submission. In this case create a Paypal button and select the item to send to Paypal. It works and you can follow the path. You can quit at the Paypal payment page. It is a demonstration although if you wish to purchase a utility from me it is a free world :) As I said it works.
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.