PHP Developers Networkhttp://forums.devnetwork.net/ Calculator Scripthttp://forums.devnetwork.net/viewtopic.php?f=14&t=139175 Page 1 of 1

 Author: peterlytham [ Mon Feb 03, 2014 6:15 pm ] Post subject: Calculator Script I'm new to this programing lark and I was wondering if someone could help.I have created a script that calculates widgets. You have to enter a value and amount and the script displays the results.Lets assume that we wanted the user to select from dropdown boxes. I.E. We have 3 types of widgets (Small, medium and large) Small widgets are say £ 50.00, medium are £100.00 and large are £ 150.00. You can only order these widgets in multiples of ten, say upto 50 max. E.G 10, 20, 30, 40, 50. (Hope I have explained that right).I know how to create dropdown boxes with select values but not sure how to change this script to incorporate them.Any help would be apreciatedPeter Syntax: [ Download ] [ Hide ]Syntax: [ Download ] [ Show ] Total Cost';                                 // Call the function with or without tax:                                 if (is_numeric(\$_POST['tax'])) {                         \$sum = calculate_total (\$_POST['quantity'], \$_POST['price'], \$_POST['tax']);                 } else {                         \$sum = calculate_total (\$_POST['quantity'], \$_POST['price']);                 }                                 // print the results:                 echo '

The total cost of purchasing ' . \$_POST['quantity'] . ' Widget(s) at £' . number_format (\$_POST['price'], 2) . ' each, with tax, is £' . \$sum . '.

';                                 } else { // invalid submitted values:         echo '

Error!

Please enter a valid quantity and price.

';         }         } // end of main isset() IF. // Leave the PHP section and create the HTML form: ?>

Widget Cost Calculator

Quantity:

Price:

Tax (%): (Optional)

 Author: requinix [ Mon Feb 03, 2014 6:39 pm ] Post subject: Re: Calculator Script I take it you know how to do their HTML? Not sure what else you might mean...That's a good first step. How about sticking it into the form you already have there? Don't mind the PHP for a moment.

 Page 1 of 1 All times are UTC - 5 hours Powered by phpBB® Forum Software © phpBB Grouphttp://www.phpbb.com/