Jump to content

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


Josepheuan

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.