Josepheuan Posted February 26, 2009 Share Posted February 26, 2009 Hi All I've got script to calculate the cost of a product based on size. At the moment I've got: <?php $height=$HTTP_POST_VARS['height']; $width=$HTTP_POST_VARS['width']; $servicefee = 0; //Allows for the adding of an extra charge $psfcost = 3.60; //cost per inch/foot/meter etc $cost = ($psfcost * $width * $height) + $servicefee; print number_format($cost, 2); ?> On the first form, I've just got 2 boxes at the moment. One for width, one for height. On some of the products I've got, theres 2 of 3 versions the customer can go for... but each version has a different price. I'd like to have a drop down menu on the first form that lets people select which product it is. How would I go about doing this? Thanks Joe Quote Link to comment https://forums.phpfreaks.com/topic/146998-solved-define-productcost-to-calculate-with-drop-down-menu/ Share on other sites More sharing options...
Josepheuan Posted February 26, 2009 Author Share Posted February 26, 2009 I'm new to PHP (as you may have guessed) But I've solved it... can't believe it was so simple! I just setup the dropdown as: <select name="dropdown" id="dropdown"> <option value="3.50" selected>Vinyl</option> <option value="3.60">Printed Colour</option> </select> And just added and changed some lines in the PHP script: Added: $dropdown=$HTTP_POST_VARS['dropdown']; Changed: $psfcost = 3.60; //cost per inch/foot/meter etc to $psfcost = $dropdown; //cost per inch/foot/meter etc Really loving PHP! Quote Link to comment https://forums.phpfreaks.com/topic/146998-solved-define-productcost-to-calculate-with-drop-down-menu/#findComment-771733 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.