Here is the code:
<script language="javascript" type="text/javascript">
function getXMLHTTP() {
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getSpan(Frame) {
var strURL="findSpan.php?Frame="+Frame;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
document.getElementById('Spandiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
function getModel(Frame,Span) {
var strURL="findModel.php?Frame="+Frame+"&Span="+Span;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
document.getElementById('Modeldiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
...
<table width="750" id="spec">
<th colspan="3">
A. Dimensions and specifiations
</th>
<tr>
<td width="190"><b>1. Snowload:</b></td>
<td width="140"><input type="text" name="load" size="2" value="<?="$load"?>" />
<?
//echo $load;
?> </td>
<td>Enter the snowload for the project area.</td>
</tr>
<tr>
<td> <b>2. Select your frame type:</b> </td>
<td>
<?
include('../global/includes/_db_info.php');
mysql_connect($dbserver,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$connection = mysql_connect($dbserver,$username,$password);
$load=@$_GET['load'];
if (empty($load)) {
$load=0;
}
$query="Select `bays`.`FS` AS `cat_id`,if((`bays`.`FS` = -(1)),'Free standing','Lean to') AS `category` from `bays` group by `bays`.`FS` order by `bays`.`FS`";
$result=mysql_query($query);
?>
<select name="Frame" onChange="getSpan(this.value)">
<option>--Select here--</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['cat_id']?>><?=$row['category']?></option>
<? } ?>
</select></td><td width="*\"><b>F</b> - Free standing:
<img src="/dealer/images/sh_e.gif" width="39" height="23" alt="Free standing" /> |<b> L</b> - Lean-to: <img src="/dealer/images/lean2.gif" width="30" height="26" alt="Lean_to" />
</td></tr>
<tr style="">
<td><b>3. Select your span:</b></td>
<td ><div id="Spandiv"><select name="Span" >
<option>--Select here--</option>
</select></div></td><td> </td></tr>
<tr style="">
<td> <b>4. Select your model:</b></td>
<td ><div id="Modeldiv"><select name="Model">
<option>--Select here--</option>
</select></div></td><td>Profile: <b>C</b> 125 (Classic) |<b> S</b> 150 (Select) |<b> T</b> 190 (Titan)<br /><br /> Model: <b>E</b>
<img src="/dealer/images/sh_e.gif" width="39" height="23" alt="E Shape 4 Frames" />
|<b> D</b> <img src="/dealer/images/sh_d.gif" width="60" height="24" alt="D Shape 6 Frames" />
|<b> V</b> <img src="/dealer/images/sh_v.gif" width="67" height="23" alt="D Shape 6 Frames" />
</td></tr>
</tr>
<tr>
<td><b>5. Length (enclosure total):</b> </td>
<td> <input type="text" name="tlength" size="2" onkeyup="data_change(this);f2m(this.form);" />ft or <input type="text" name="lm" size="4" onkeyup="m2f(this.form);" />m</td>
<td>The optimum length for the encloure should be multiples of 7ft/2.14m.</td>
</tr>
</table>
findspan.php:
<? $Frame=intval($_GET['Frame']);
include('../global/includes/_db_info.php');
mysql_connect($dbserver,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$connection = mysql_connect($dbserver,$username,$password);
mysql_select_db('db1');
$query="SELECT span FROM bays where fs=$Frame group by span order by span";
$result=mysql_query($query);
?>
<select name="Span" onchange="getModel(<?=$Frame?>,this.value)">
<option>--Select here--</option>
<? while($row=mysql_fetch_array($result)) {
$spanm=round(($row['span'])*0.3048,2);
$mystring=intval($row['span'])."ft :: ".$spanm."m";
?>
<option value=<?=$row['span']?>><?=$mystring?></option>
<? } ?>
</select>
findmodel.php:
<? $Frame=intval($_GET['Frame']);
$Span=intval($_GET['Span']);
include('../global/includes/_db_info.php');
mysql_connect($dbserver,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$connection = mysql_connect($dbserver,$username,$password);
mysql_select_db('db1');
$query="SELECT qbay.type as type, qbay.load as myload, qbay.bprice/(qbay.length*qbay.span) as myprice, qbay.length as width FROM qbay where qbay.span=$Span and qbay.fs=$Frame order by myprice, qbay.load, qbay.type";
$result=mysql_query($query);
?>
<select name="Model">
<option>--Select here--</option>
<? while($row=mysql_fetch_array($result)) {
$myvalue=$row['type'].$row['width'];
$mystring2=$row['type']." : ".number_format($row['myprice'],2)."$/sqf : ".number_format($row['width'],0)."'bays : ".number_format($row['myload'],0)."psf";
?>
<option value='<?=$myvalue?>'><?=$mystring2?></option>
<? } ?>
</select>