eideticmnemonic Posted November 28, 2007 Share Posted November 28, 2007 Hi. I'm probably the biggest n00b ever, so I apologize in advance for what is surely a very dumb question. :S Fyi, I've been trying to get this to work myself all day long before posting here. I want to create an order form which includes 2 drop down menus, StartLength and EndLength, the menu options for both being: 0-10 min 10-30 min 30-60 min The respective values for each option are: 25 50 100 (the user should not see these values.) The total cost will be displayed and will be the average of the two values. I've tried several different things, and nothing has really worked. Here is the code I have at the moment.... I'm sure it's atrocious. :S <?php // initialize or capture variable $StartLength = !isset($_POST['startLength'])? NULL : $_POST['startLength']; ?> <select name="startLength"> <option value="25">0-10</option> <option value="50">10-30</option> <option value="100">30-60</option> </select> <?php $EndLength = !isset($_POST['EndLength'])? NULL : $_POST['EndLength']; ?> <select name="EndLength"> <option value="25">0-10</option> <option value="50">10-30</option> <option value="100">30-60</option> </select> <?php $numStartLength = $_Post[startLength]; $numEndLength = $_Post[EndLength]; $numvfx = $_Post[vfx]; $totalcost = ($numStartLength + $numEndLength)/2; ?> <BR><BR> Your total is: <?php echo number_format($totalcost,2,'.',','); ?>. Quote Link to comment Share on other sites More sharing options...
s0c0 Posted November 28, 2007 Share Posted November 28, 2007 first verify you get anything in the $_POST by doing a print_r($_POST). It looks like your form name for the start is startLength whereas you are attempting to extract data from $_Post[startLength]. See the difference, one is capitalized, this will cause a problem. Basically if the data is in both $_POST elements for the start and end you should just need to those two $_POST elements together, number format them, and display to the screen. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 28, 2007 Share Posted November 28, 2007 You need a submit button, here is some working code that I think does what you want. <form method="post"> <select name="startLength"> <option value="25">0-10</option> <option value="50">10-30</option> <option value="100">30-60</option> </select> <select name="EndLength"> <option value="25">0-10</option> <option value="50">10-30</option> <option value="100">30-60</option> </select> <input type="submit" name="submit" value="Add Values!"> </form> <?php if(isset($_POST['submit'])){ $start = $_POST['startLength']; $end = $_POST['EndLength']; $totalcost = ($start + $end)/2; echo '<BR><BR>'; echo 'Your total is: '. number_format($totalcost,2,'.',','). '.'; } ?> When you press submit it will give you the total cost. Quote Link to comment Share on other sites More sharing options...
eideticmnemonic Posted November 28, 2007 Author Share Posted November 28, 2007 THANK YOU SO MUCH!! That was driving me absolutely crazy! You've made my day! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.