I have this script and it is performing the calculations to provide an instant price quote script fine in IE and also making only certain boxes editable when a certain radio button is clicked. However in Firefox or Safari it isn't working. I think it is the javascript that isn't working.
Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
td.calchead{
width:75px;
background:none;
border-top:thin solid black;
text-align:right;
}
td.calc{
width:75px;
background:none;
border:thin solid black;
text-align:right;
}
td.products{
float:right;
text-align:right;
border:1px solid black;
}
td.inputs{
width:200px;
float:right;
text-align:right;
}
p.products{
text-align:left;
font-family:Georgia, "Times New Roman", Times, serif, 14px;
}
p.inputs{
text-align:left;
font-family:Georgia, "Times New Roman", Times, serif, 14px;
}
input.inputs{
width:30px;
background-color:CCCCCC;
}
p.calculate{
text-align:left;
font-family:Georgia, "Times New Roman", Times, serif, 14px;
}
</style>
<?php
$header = $_POST['header'];
$productid = $_POST['group1'];
$width = $_POST['width'];
$height = $_POST['height'];
$openings = $_POST['openings'];
$clearpanel = $_POST['clearpanel'];
$resident = $_POST['resident'];
$color = $_POST['color'];
$motor = $_POST['motor'];
$priceperheader=.5833;
//error checking, ensures all variables are numeric between calculatable values 0 and 999
if($width>=0 && $width<=999 && $height>=0 && $height<=999 && $openings>=0 && $openings<=999 && $clearpanel>=0 && $clearpanel<=999)
{
$width2=$width+6;
$height2=$height+6;
if($productid == 'Roll-down Shutters')
{
$height2=$height2+4;
}
$wh=$width2*$height2;
if($header=='yes')
{
$he=$openings*$width;
$he=$he*$priceperheader;
}
else
{
$he=0;
}
if($resident=='yes')
{
$tax=1.085;
}
else
{
$tax=1;
}
if($motor=='2')
{
$motor=488*$openings;
}
else
{
$motor=0;
}
//$cl=$clearpanel*$priceperclearpanel;
//echo(' ' + $wh + ' ' + $he + ' ' + $cl + ' ');
//divide sq ft by 144 to get sq inches
////.050 alum =$4.94 per sq ft
////24 gauge steel =$3.72 per sq ft
////change Protexan to Lexan =9.94 sq ft
////roll downs = $24.99 per sq ft motor = $488.
////bahama impact = 25.99 sq ft no impact 21 per sq ft
////colonial impact = 25.99 and non = 21 sq ft
////Hurricane Fabric $6.38 per sq ft
//All prices are self install only installation is extra and highly reccommended
////F track = $1.79 per ft
////H track = $2.29 per ft
////Texas residents add 8.25 percent sales tax
//Standard Clamshell<input type='radio' name='group1' value='Standard Clamshell' onFocus="enable5()"><br />
//Impact Clamshell<input type='radio' name='group1' value='Impact Clamshell' onFocus="enable5()"><br />
//.063 Aluminum Panels<input type='radio' name='group1' value='.063 Aluminum Panels' onFocus="enable1()"><br />
//Accordian Shutters<input type='radio' name='group1' value='Accordian Shutters' onFocus="enable4()" /><br />
function sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2)
{
$wh=$wh*$priceperopening;
$subtotal=$wh+$he;
$subtotal=$subtotal+$motor;
$total=$subtotal*$tax;
$tax=$total-$subtotal;
echo("<table><tr ><td>Product</td><td>Measured Opening</td><td>Finished Opening</td></tr>
<tr><td >" . $productid . "</td><td align'right'>" . $width . " x " . $height . "</td><td align'right'>" . $width2 . " x " . $height2 . "</td></tr></table>
<table><tr><td></td><td class='calchead'>Shutter</td><td class='calchead'>Header</td><td class='calchead'>Motor</td><td class='calchead'>Tax</td><td class='calchead'>Total</td></tr>
<tr><td>$</td><td class='calc'>". money_format('%.2n',$wh) . "</td><td width='30' class='calc'>". money_format('%.2n',$he) . "</td><td width='30' class='calc'>" . money_format('%.2n',$motor) . "</td><td width='30' class='calc'>" . money_format('%.2n',$tax) . "</td><td align='right' class='calc'>$" . money_format('%.2n',$total) . "</td></tr></table>");
}
if($productid == '.050 Aluminum Panels')
{
$priceperopening=.03431;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == '24 gauge steel')
{
$priceperopening=.02583;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == 'lexan')
{
$priceperopening=.0659;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == 'Roll-down Shutters')
{
$priceperopening=.17354;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == 'Impact Bahama Shutters')
{
$priceperopening=.18049;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == 'Impact Colonial Shutters')
{
$priceperopening=.18049;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == 'Hurricane Fabric')
{
$priceperopening=.04431;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == 'Non-Impact Bahama Shutters')
{
$priceperopening=.14583;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
if($productid == 'Non-Impact Colonial Shutters')
{
$priceperopening=.14583;
sum($productid, $priceperopening, $wh, $he, $tax, $motor, $width, $height, $width2, $height2);
}
}
else
{echo('Please make sure to enter numbers greater than zero and less than 999 in all required fields.');}
$header='';
?>
<script type='text/javascript'>
//white() clears backs of inputs to white and is called from eable functions
function white(){
document.getElementById("header").style.background='#ffffff';
document.getElementById("width").style.background='#ffffff';
document.getElementById("height").style.background='#ffffff';
document.getElementById("openings").style.background='#ffffff';
document.getElementById("resident").style.background='#ffffff';
document.getElementById("color").style.background='#ffffff';
document.getElementById("motor").style.background='#ffffff';
}
//enable1-5() enables particular requested fields specific for product type and disables unused fields.
function enable1()
{
white();
document.getElementById("header").disabled='';
document.getElementById("width").disabled='';
document.getElementById("height").disabled='';
document.getElementById("openings").disabled='';
document.getElementById("resident").checked='';
document.getElementById("resident").disabled='';
document.getElementById("color").style.background='#CCCCCC';
document.getElementById("color").value='';
document.getElementById("color").disabled='true';
document.getElementById("motor").style.background='#CCCCCC';
document.getElementById("motor").value='';
document.getElementById("motor").disabled='true';
}
function enable2()
{
white();
document.getElementById("header").disabled='';
document.getElementById("width").disabled='';
document.getElementById("height").disabled='';
document.getElementById("openings").disabled='';
document.getElementById("resident").checked='';
document.getElementById("resident").disabled='';
document.getElementById("color").value='';
document.getElementById("color").style.background='#CCCCCC';
document.getElementById("color").disabled='true';
document.getElementById("motor").value='';
document.getElementById("motor").style.background='#CCCCCC';
document.getElementById("motor").disabled='true';
}
function enable3()
{
white();
document.getElementById("header").checked='';
document.getElementById("header").style.background='#CCCCCC';
document.getElementById("header").disabled='true';
document.getElementById("width").disabled='';
document.getElementById("height").disabled='';
document.getElementById("openings").disabled='';
document.getElementById("resident").disabled='';
document.getElementById("resident").checked='';
document.getElementById("color").disabled='';
document.getElementById("motor").disabled='';
}
function enable4()
{
white();
document.getElementById("header").checked='';
document.getElementById("header").style.background='#CCCCCC';
document.getElementById("header").disabled='true';
document.getElementById("width").disabled='';
document.getElementById("height").disabled='';
document.getElementById("openings").disabled='';
document.getElementById("resident").checked='';
document.getElementById("resident").disabled='';
document.getElementById("color").disabled='';
document.getElementById("motor").style.background='#CCCCCC';
document.getElementById("motor").value='';
document.getElementById("motor").disabled='true';
}
function enable5()
{
white();
document.getElementById("header").checked='';
document.getElementById("header").disabled='true';
document.getElementById("header").style.background='#CCCCCC';
document.getElementById("width").disabled='';
document.getElementById("height").disabled='';
document.getElementById("openings").disabled='';
document.getElementById("resident").checked='';
document.getElementById("resident").disabled='';
document.getElementById("color").value='';
document.getElementById("color").disabled='true';
document.getElementById("color").style.background='#CCCCCC';
document.getElementById("motor").value='';
document.getElementById("motor").disabled='true';
document.getElementById("motor").style.background='#CCCCCC';
}
</script>
<title>Estimator</title>
</head>
<body>
<div>
<table>
<tr>
<td><p class='products'>First, select a product</p></td>
<td><p class='inputs'>Then, enter dimensions and select options (in inches) that appear in white</p></td>
</tr>
<tr>
<td class='products'>
<form width='550' name='form01' method='post' action='http://www.windowguardoftexas.com/estimator.php'>
.050 Aluminum Panels<input type='radio' name='group1' value='.050 Aluminum Panels' onFocus="enable1()"><br />
24 Gauge Steel<input type='radio' name='group1' value='24 gauge steel' onFocus="enable1()"><br />
Lexan<input type='radio' name='group1' value='lexan' onFocus="enable2()"><br />
Roll-down Shutters<input type='radio' name='group1' value='Roll-down Shutters' onFocus="enable3()"><br />
Impact Bahama Shutters<input type='radio' name='group1' value='Impact Bahama Shutters' onFocus="enable4()"><br />
Impact Colonial Shutters<input type='radio' name='group1' value='Impact Colonial Shutters' onFocus="enable4()"><br />
Hurricane Fabric<input type='radio' name='group1' value='Hurricane Fabric' onFocus="enable5()"><br />
Non-Impact Bahama Shutters<input type='radio' name='group1' value='Non-Impact Bahama Shutters' onFocus="enable4()"><br />
Non-Impact Colonial<input type='radio' name='group1' value='Non-Impact Colonial Shutters' onFocus="enable4()"><br />
</td>
<td class='inputs'>
Add Header and F-track to openings: <input type='checkbox' name='header' class='inputs' value='yes' disabled="disabled"/><br />
Width: <input type='text' class='inputs' name='width' value='' maxlength='3'disabled='disabled' /><br />
Height: <input type='text' class='inputs' name='height' value='' maxlength='3' disabled='disabled' /><br />
Openings: <input type='text' class='inputs' name='openings' value='' maxlength='3' disabled='disabled' /><br />
Texas Resident <input type='checkbox' name='resident' class='inputs' value='yes' disabled="disabled"/><br />
Color: <select name="color" id='color' class='inputs' disabled='disabled'><br />
<option value="0" >--Select Color--</option>
<option value="1" >White</option>
<option value="2">Bronze</option>
<option value="3">Ivory</option>
<option value="3">Beige</option>
</select>
<br />
Motor: <select name="motor" class='inputs' disabled="disabled"><br />
<option value="0">--Select Motor--</option>
<option value="1">None</option>
<option value="2" >Standard</option>
</select>
<br /><br />
<p class='calculate'>Finally, press calculate</p>
<input type='reset' name='Submit2' value='Reset'>
<input type='submit' name='Submit' value='Calculate'>
</td>
</form>
</tr>
<tr><td>All prices are self install only, installation</td><td>is extra and highly reccommended</td></tr>
</table>
</div>
</body>
</html>
How do I get this to work in Firefox and Safari? Why would it work in IE but not the others?