Get the SUM of several drop-down...

User 2486034 Photo


Registered User
2 posts

I have a form with several drop down fields. Each drop down has several quantity choices.
Is it possible to keep a running total of choices made?
Is it possible to check that the total is below a number and above a number?
If Total is <400 and >2000 then hide submit button
If the condition is not met, hide the submit button and display an error message.

So, to further define the rule I will try to show you logically:
Drop down 1 = 200
Drop down 2 = 800
Drop down 3 = 800
Total = 1800
Submit button is displayed
or
Drop down 1 = 800
Drop down 2 = 800
Drop down 3 = 800
Total = 2400
Submit button is hidden
Error message displayed - "You must lower the number of forms ordered"
http://onsetscriptpads.com/order/
The user does not pay for these forms on-line.
Thanks

User 38401 Photo


Senior Advisor
10,951 posts

Right now you'd need to do that with outside scripts as the form builder doesn't have that capability. I know they talked about adding calculations, not sure if that will include tallies or not, but I guess we'll have to see.
User 464893 Photo


Ambassador
1,611 posts

Jo Ann is right but if you send the data to a database or csv file you can display the result of the last entry.
Check out Eric's site I believe he has some examples of how it can be achieved. Totalling the result can be done by the same script, even adding a quote, from there an order could be generated.

The Guy from OZ


User 2486034 Photo


Registered User
2 posts

Thanks for your suggestions. I will post a solution if I implement one :/
This problem may very well be a deal breaker.
User 464893 Photo


Ambassador
1,611 posts

I prefer to use csv files to store information mainly as I am not having to worry about mega entries. the csv can be downloaded and Excel or Access used to report findings. but to make data readily available this simple script will grab data from the last incoming entry.

<?php
$file_handle = fopen("results.csv", "r");// the address where the file is located
while (!feof($file_handle)){
$item = fgetcsv($file_handle, 1024);
if($item=="")Break;// make sure the last entry is used
$lastitem=$item;
}
fclose($file_handle);

$option= $lastitem[0]; // number from 0 gives the first item in the entry list 3 = the forth and so on
$option =$lastitem[0]+$lastitem[1]+$lastitem[2]; addition of values items 1 2 and 3
?>

The display is a html file with a php extension and where you show a result simply insert code like this
<?php echo $option ?> from above in this case the variable just holds the first(0) entry (1) is the next and so on.


From the above example the variable $lastitem actually holds the whole entry so any data can be extracted and used, Date, Time and any other data entered can be displayed as desired.

You can do the same with a database once you select your items I just like using csv files as WFB creates them beautifully
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.