I have created a populated dropdown list in HTML. When the two dropdowns have been selected, the form posts to 'calculate.php' where the php script echoes out the selected values from the dropdowns.
<form action="calculate.php" method='POST'>
<select name="Phones">
<option value="Lumia800">Nokia Lumia 800</option>
<option value="iPhone">Apple iPhone 4s</option>
<option value="GalaxyS2">Samsung Galaxy S2</option>
<option value="Bold9900">Blackberry Bold 9900</option>
<option value="SensationXE">HTC Sensation XE</option>
<option value="XperiaS">Sony Ericsson Xperia S</option>
</select>
<select name="Network">
<option value="Orange">Orange</option>
<option value="Vodafone">Vodafone</option>
<option value="O2">O2</option>
<option value="Three">Three</option>
</select>
<input type="submit" />
</form>
In this one example, 'calculate.php' echoes the selected dropdown values.
<?php
$pref=$_POST['Phones'];
$pref1=$_POST['Network'];
$Orange="5";
if ($pref1 == "Orange")
{
$total1 = $Orange;
}
$Lumia800="10";
if ($pref == "Lumia800")
{
$total = $Lumia800 + $Orange;
}
echo $total;
?>
This example output is '15'
The aim of this example is to eventually create a simple phone package system, with this set of code adding the price of the phone, the network costs, and other variables together for a final total of how much it would cost when the user submits it.
The problem I have is that I want to add each variable from the corresponding dropdown boxes ("Phones" and "Network" for example) against each other. Is my example going to be too over complicated for such a simple script? Is there a more refined method to get the results that I want?
Thanks,
JB.