Hey! I programmed a form which dynamically calculates the price. You can select between 2 packages.
<input type="radio" id="p1" onclick="doWork();" name="package"/>
<input type="radio" id="p2" onclick="doWork();" name="package"/>
In Ajax I send the value to a php file.
function doWork(){
httpObject = getHTTPObject();
if (httpObject != null) {
var url = "price.php?p1=" + document.getElementById('p1').value + "&p2=" + document.getElementById('p2').value;
httpObject.open("GET", url, true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}
Inside the php file I do
<?php
$price = 0;
if ($_GET['p1'] == 'on') $price += 1;
if ($_GET['p2'] == 'on') $price += 2;
echo $price."$";
?>
In Safari it shows the right price. But in Firefox I always get the price 3. I doesn't change if I choose 1 or 2 it always is the sum of 1 and 2.
What do I have to change?
Thanks!