Alex L Posted December 18, 2009 Share Posted December 18, 2009 Hi, I've tried to find a solution for this but I've had no luck. I don't really mind how it works as long as it gets the job done. So, what I've tried to do is make a system which estimates the price of something and then emails the information. So, say I have a dropdown menu with two options, one which is £10, one which is £20, I want the estimated value to change depending on what is selected. Is there a way to do this, eaither on the page or as a separate page called quote.php or something like that. My current code is below. <form method="post" action="sendmail.php"> <div id="left"> <p><b>Name:</b><br /><input type="text" name="name" /></p> <p><b>Daytime Number:</b><br /><input type="text" name="daytime" /></p> <p><b>Address Line 1:</b><br /><input type="text" name="address1" /></p> <p><b>City/Town:</b><br /><input type="text" name="citytown" /></p> <p><b>Postcode:</b><br /><input type="text" name="postcode" /></p> <p><b>Cake Type:</b><br /><select name="caketype"> <option>Fruit cake +£0<?php $caketype=0; ?></option> <option>Sponge +£20<?php $caketype=20; ?></option> <option>Chocolate +£30<?php $caketype=30; ?></option> </select></p> <p><b>Tiers:</b><br /><select name="tiers"> <option>1 Tier +£0<?php $tiers=0; ?></option> <option>2 Tiers +£20<?php $tiers=20; ?></option> <option>3 Tiers +£40<?php $tiers=40; ?></option> <option>4 Tiers +£60<?php $tiers=60; ?></option> <option>5 Tiers +£80<?php $tiers=80; ?></option> <option>6 Tiers +£100<?php $tiers=100; ?></option> </select></p> <?php $base = 100; $quote=($base+$caketype+$tiers+$decorativebox);?><h4>Estimated Price: £<?php echo $quote; ?></h4> <p><input type="submit" value="Submit Message"/><input type="reset" /></p> </div> <div id="right"> <p><b>Email:</b><br /><input type="text" name="email" /></p> <p><b>Mobile Number:</b><br /><input type="text" name="mobile" /></p> <p><b>Address Line 2:</b><br /><input type="text" name="address2" /></p> <p><b>County:</b><br /><input type="text" name="county" /></p> <p><b>Message:</b><br /><textarea name="message" cols=30 rows=3></textarea></p> <p><b>Extras:</b><br /> <input type="checkbox" name="decorativebox" value="decorativebox"<?php if (isset($_POST['decorativebox'])) {$decorativebox = 25;} else {$decorativebox = 0;} ?>/>Decorative Box +£25<br /> <input type="checkbox" name="checkbox" value="Test 2" />Test 2<br /> <input type="checkbox" name="checkbox" value="Test 3" />Test 3<br /> <input type="checkbox" name="checkbox" value="Test 4" />Test 4<br /> <input type="checkbox" name="checkbox" value="Test 5" />Test 5</p> <br /> </div> </form> Thanks to anyone that can help. Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/ Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 u just need a loop Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979832 Share on other sites More sharing options...
Alex L Posted December 18, 2009 Author Share Posted December 18, 2009 Could you expand on that please. I'm not really sure what to do, could you point me to some examples I could use? Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979850 Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 we;; nt much to ecpand on a loo[ hon. is just a foreach($c > 9 $c++){post the variables then insert into database) Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979855 Share on other sites More sharing options...
Alex L Posted December 18, 2009 Author Share Posted December 18, 2009 Sorry, I don't understand what to do and I'm not using a database, I was trying to do it without having to. Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979857 Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 i looe at ur code again it doesnt make sense are u trying to echo $tiers; cause u just have <?php $tier; ?> makes no sense Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979860 Share on other sites More sharing options...
oni-kun Posted December 18, 2009 Share Posted December 18, 2009 Sorry, I don't understand what to do and I'm not using a database, I was trying to do it without having to. I'm not 100% sure what you wish to do. Do you want the estimate to be added upon 10 pounds if it goes up from 10->20 in the selection box? Wherever your actions are to take the POST data from the selection box, you may want to add it into a session variable (if you can not create a session, look for a tutorial, it's simple). Once you submit the form it'll simply be like.. $_SESSION['estimate_total'] += 10;.. So you can echo it like "Your estimate cost is ". $_SESSION['estimate_total'] . "pounds". EDIT: If you want it to be automatic (I.E.: Not refreshing the page) You'll need to use AJAX to query quote.php and fill in the value.. Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979861 Share on other sites More sharing options...
JAY6390 Posted December 18, 2009 Share Posted December 18, 2009 This would be better done as a javascript update based on the values of the dropdowns I dont think you understand the difference between a server side script and a client side script. client side is what you want, and PHP is server side. Use javascript to do the dropdown quote, then parse the values from the form using php Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979879 Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 ya this is just unequiical. wrong forum completely dude. think next time u post in the PHP forum fpor JAVASCRIPT help. embarassing Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979935 Share on other sites More sharing options...
mrMarcus Posted December 18, 2009 Share Posted December 18, 2009 think next time u post in the PHP forum likewise. we;; nt much to ecpand on a loo[ hon. i ran that through Google translator, and it vomited. Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979943 Share on other sites More sharing options...
JAY6390 Posted December 18, 2009 Share Posted December 18, 2009 i ran that through Google translator, and it vomited. :happy-03:roflmao Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979951 Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 tHAT HAS NOT A DANG HTING TO DOW ITH THE OPS POST! wth guys seriously? Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-979971 Share on other sites More sharing options...
oni-kun Posted December 18, 2009 Share Posted December 18, 2009 think next time u post in the PHP forum likewise. we;; nt much to ecpand on a loo[ hon. i ran that through Google translator, and it vomited. I laughed so hard I almost cried. Rofl.. OP, need anything else? Link to comment https://forums.phpfreaks.com/topic/185594-quoteestimate/#findComment-980047 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.