Jump to content

[SOLVED] Define product/cost to calculate with drop down menu?


Recommended Posts

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

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.