i have a code here where a user can search a specific trip and can choose his/her preferred seat..
my problem is when computing the total fee for the reservation being made, i can't count the number of times a user check a seat...

by the way, the output for the total fee will be posted in another page..

pls.. help me.. tnx in advance

i know it's a long code

<?php

include_once('functions.php');
include_once('database.php');

$database = new Database();
$database->Connect();


$BusCode = "Type1";

// select Generator
$values = array();
$values[] = "DepartureName";
$sql = "SELECT * FROM departure";
$rs = $database->executeQuery($sql);
$DepartureList = selectGenerator($rs, "DepartureID", "DepartureID", $_POST['DepartureID'], $values);
// End

// select Generator
$values = array();
$values[] = "DestinationName";
$sql = "SELECT * FROM destination";
$rs = $database->executeQuery($sql);
$DestinationList = selectGenerator($rs, "DestinationID ", "DestinationID", $_POST['DestinationID_'], $values);
// End

if ($_POST) {
	
		if ($_POST['cancel'] == 'Cancel') {
			header("Location:bus1.php");
		}
		
		//$sql = "INSERT INTO "; - ung sa bus type
		if ($_POST['reserve'] == "reserve") {

			$query = "SELECT * FROM route INNER JOIN buslist ON buslist.BusListID = route.BusListID 
					INNER JOIN bustype ON bustype.BusTypeID = buslist.BusTypeID 
					INNER JOIN departure ON departure.DepartureID = route.FromDest 
					INNER JOIN destination ON destination.DestinationID = route.ToDest WHERE 
					route.FromDest = {$_POST['DepartureID']} AND route.ToDest = {$_POST['DestinationID_']} 
					AND route.DepartureDate = '{$_POST['DepartureDate']}' AND bustype.BusTypeID = {$_POST['BusTypeID']}";
			
			$rs = $database->executeQuery ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
			if (mysql_num_rows($rs) > 0) {
				$rw = mysql_fetch_array($rs);
				$RouteID = $rw["RouteID"];
			}
			
			if ($rw["BusTypeDesc"] == 'BusType2' ) {
				header("Location:bus2.php?RouteID={$RouteID}&ShowSeat=1&DepartureID={$_POST['DepartureID']}&DestinationID={$_POST['DestinationID_']}&DepartureDate={$_POST['DepartureDate']}");
			} else {
				header("Location:bus1.php?RouteID={$RouteID}&ShowSeat=1&DepartureID={$_POST['DepartureID']}&DestinationID={$_POST['DestinationID_']}&DepartureDate={$_POST['DepartureDate']}");
			}
			
			//$RecordFound = true;
						
		}	
		// sa seats
		if ($_POST['submit'] == "Reserve") {
			
				
			foreach($_POST AS $field => $value) {
				//echo "field = $field, value = $value";
				if ($field != "submit") {
				$sql = "INSERT INTO reservation (ClientID, RouteID, BusTypeCode, SeatNo, IsPaid, AmountPaid) VALUES 
						(2, {$_REQUEST['RouteID']}, '{$BusCode}', {$value}, 0, 0)";
				
				$database->executeNonQuery($sql);
				//echo $sql;
				//redirect
				header("Location:passenger_fillup.php");
				}
			}

		}
		
		if ($_POST['Search'] == "search") {

			//Check are taken from reservation
			$query = "SELECT * FROM route INNER JOIN buslist ON buslist.BusListID = route.BusListID 
					INNER JOIN bustype ON bustype.BusTypeID = buslist.BusTypeID 
					INNER JOIN departure ON departure.DepartureID = route.FromDest 
					INNER JOIN destination ON destination.DestinationID = route.ToDest 
					WHERE 
					route.FromDest = {$_POST['DepartureID']} AND route.ToDest = {$_POST['DestinationID_']} 
					AND route.DepartureDate = '{$_POST['DepartureDate']}'";
			
			$rs = $database->executeQuery ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
			
			
			if (mysql_num_rows($rs) > 0) {
				$result = "<center><br><b><font color=\"#FFFFFF\">" . mysql_num_rows($rs) . " record(s) found</center></font></b>";
				
				$sql = "SELECT * FROM buslist INNER JOIN bustype ON buslist.BusTypeID = bustype.BusTypeID 
						WHERE BusListID = ";
				while($rw = mysql_fetch_array($rs)){
					$sql .= $rw['BusListID'] . " AND BusListID = ";
					// Select avaiable bus BusListID
				}
				
				$sql = substr($sql, 0, (strlen($sql)-17));
				$values = array();
				$values[] = "BusTypeDesc";
				$rs = $database->executeQuery($sql);
				$SearchResultBusList = selectGenerator($rs, "BusTypeID", "BusTypeID", $_POST['BusTypeID'], $values);
				
				$result .= "<br>";
				$result .= $SearchResultBusList;

			} else {
				//$result = "
//				<center><b>No records found</b></center>
//				";
				$result= "
				<center><b>No records found</b></center>";
				
				
			}
			
		}
		

	//$_POST['DepartureDate'] = date("m/d/y");
	

} else {
	
	if ($_REQUEST['RouteID']!="") {
		
		// Check list of reservation
		$sql = "SELECT * FROM reservation WHERE RouteID = {$_REQUEST['RouteID']} AND BusTypeCode = 'Type1'";
		$rs = $database->executeQuery ($sql) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
		if (mysql_num_rows($rs) > 0) {
			// filter the one with reservation
			// para ung checkbox and color.. maalis
			$s = array();
			$c = array();
			while($rw = mysql_fetch_array($rs)){
				//echo "here";
				for ($x=1; $x<40; $x++) {
					if ($rw['SeatNo'] == $x) {
						$s[$x] = " disabled";
						$c[$x] = "style=\"background-color:#cc3333;\"";
					} 
				}
				
			}
		} 

	}
	
//echo "<pre>";
//print_r($c);
//echo "</pre>";
}


$database->Disconnect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
	<script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script>
	
	<Style>
BODY, P,TD{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 10pt }
A{font-family: Arial,Verdana,Helvetica, sans-serif;}
B {	font-family : Arial, Helvetica, sans-serif;	font-size : 12px;	font-weight : bold;}
</Style>

<link rel="stylesheet" type="text/css" media="all" href="jsDatePick.css">
<script type="text/javascript" src="jsDatePick.min.1.0.js"></script>
<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"inputField"
			//limitToToday:true <-- Add this should you want to limit the calendar until today.
		});
	};
</script>
	<script language="JavaScript">
	var bgcolorSelected = "#cc3333";	
	var bgcolorNotSelected = "black";
	
	function HighLightTR1(el){
		if (document.myform.s1.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
	function HighLightTR2(el){
		if (document.myform.s2.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
	function HighLightTR3(el){
		if (document.myform.s3.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
	function HighLightTR4(el){
		if (document.myform.s4.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR5(el){
		if (document.myform.s5.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR6(el){
		if (document.myform.s6.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR7(el){
		if (document.myform.s7.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR8(el){
		if (document.myform.s8.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR9(el){
		if (document.myform.s9.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR10(el){
		if (document.myform.s10.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR11(el){
		if (document.myform.s11.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR12(el){
		if (document.myform.s12.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR13(el){
		if (document.myform.s13.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR14(el){
		if (document.myform.s14.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR15(el){
		if (document.myform.s15.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR16(el){
		if (document.myform.s16.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR17(el){
		if (document.myform.s17.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR18(el){
		if (document.myform.s18.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR19(el){
		if (document.myform.s19.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR20(el){
		if (document.myform.s20.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR21(el){
		if (document.myform.s21.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR22(el){
		if (document.myform.s22.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR23(el){
		if (document.myform.s23.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR24(el){
		if (document.myform.s24.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR25(el){
		if (document.myform.s25.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR26(el){
		if (document.myform.s26.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR27(el){
		if (document.myform.s27.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR28(el){
		if (document.myform.s28.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR29(el){
		if (document.myform.s29.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR30(el){
		if (document.myform.s30.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR31(el){
		if (document.myform.s31.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR32(el){
		if (document.myform.s32.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR33(el){
		if (document.myform.s33.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR34(el){
		if (document.myform.s34.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR35(el){
		if (document.myform.s35.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR36(el){
		if (document.myform.s36.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR37(el){
		if (document.myform.s37.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR38(el){
		if (document.myform.s38.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	function HighLightTR39(el){
		if (document.myform.s39.checked == true) {
			el.bgColor=bgcolorSelected;
		} else {
			el.bgColor=bgcolorNotSelected;
		}						
	}
			
	</script>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>BuckleUp Online Reservation</title>
	</head>
	<link href="style.css" rel="stylesheet" type="text/css" media="screen">
	<body>
	<div id="wrapper">
	<div id="header">
		<div id="menu">
			<ul>
				<li class="current_page_item"><a href="index.html">Home</a></li>
				<li><a href="penafrancia.htm">Peñafrancia</a></li>
				<li><a href="philtranco.htm">Philtranco</a></li>
				<li><a href="silverstar.htm">Silver Star</a></li>
				<li><a href="cancellation.htm">Cancellation</a></li>
				<li><a href="faqs.htm">FAQS</a></li>
			</ul>
		</div>
		<!-- end #menu -->
		
	</div>
		<div id="logo">
			<center><img border="0" src="images/buckleup.jpg" width="800" height="300"></center>
	</div>
	<div id="page">
___________________________________________________________________________________________________________________
<br><br><br>
	

	
<?php
	//include_once('header.php');
	//include_once('menu.php');
?>

<?php 
if ($_REQUEST['status'] == 1) {
	echo "<p>Youre reservation is done, please pay at the office.</p>";
} 
?>


<?php if ($_REQUEST['ShowSeat']!='1') { ?>	
	

<form name="search" action="" method="POST">
	<center>
		<b><font color="#FFFFFF">From</font> </b> 
		<?php echo $DepartureList ?><br><br>
		<b><font color="#FFFFFF">To</font></b>&nbsp;&nbsp;&nbsp;&nbsp;
		<?php echo $DestinationList ?><br><br>
			<b><font color="#FFFFFF">Date</font> </b>
		<input type="text" size="12" id="inputField" name="DepartureDate" value="<?php echo $_POST['DepartureDate']; ?>">
	<!--	<input type="text" name="DepartureDate" value="<?php echo $_POST['DepartureDate']; ?>">-->
	
		<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	
		<input type="submit" name="Search" value="search"><br>
		__________________________________________________
				</center>	


	<?php if ($result != '')  { ?>
	<?php echo $result; ?>
		<input type="submit" name="reserve" value="reserve">	
	<?php } ?>

<?php } ?>
</form>	 

</li>	
</ul>
</div>
</div>



<?php if ($_REQUEST['ShowSeat']=='1') 
{ 

$database->Connect();
$sql = "SELECT * FROM departure WHERE DepartureID = {$_REQUEST['DepartureID']}";
$rs = $database->executeQuery($sql);
$row = mysql_fetch_array($rs);

echo "

<font color=\"#FFFF00\"><b>

FROM: </font></b> <font color=\"#FFFFFF\">{$row['DepartureName']}</font>"; 

$sql = "SELECT * FROM departure WHERE DepartureID = {$_REQUEST['DepartureID']}";
$rs = $database->executeQuery($sql);
$row = mysql_fetch_array($rs);

$sql = "SELECT * FROM destination WHERE DestinationID = {$_REQUEST['DestinationID']}";
$rs = $database->executeQuery($sql);
$row = mysql_fetch_array($rs);

echo "<br>

<font color=\"#FFFF00\"><b>

TO: </font></b> <font color=\"#FFFFFF\">{$row['DestinationName']}</font>";

$sql = "SELECT * FROM route WHERE RouteID = {$_REQUEST['RouteID']}";
$rs = $database->executeQuery($sql);
$row = mysql_fetch_array($rs);

echo "<br>
<font color=\"#FFFF00\"><b>

DEPARTURE DATE: </font></b> <font color=\"#FFFFFF\">{$_REQUEST['DepartureDate']}</font>" .

"<br> 
<font color=\"#FFFF00\"><b>

DEPARTURE TIME: </font></b> <font color=\"#FFFFFF\">{$row['TimeDest']}</font>" .

"<br>
<font color=\"#FFFF00\"><b>

ETA: </font></b> <font color=\"#FFFFFF\">{$row['TimeADest']}</font>" . 

"<br>
<font color=\"#FFFF00\"><b>

AMOUNT (PESO) : </font></b> <font color=\"#FFFFFF\">{$row['Amount']}</font>";

$database->Disconnect();
?>
<form name="myform" action="" method="POST">
	<div align="center">
	<br><br>
		<table border="1" style="font-size:10px;" width="300">
			<td height="50" width="50"><font color="red">Back</font></td>
			</table>
		<table border="1" style="font-size:10px;" width="300">
		
			<tr align="center">
				<td height="50" width="50"><font color="#FFFFFF">Co-Driver's Seat</font></td>
				<td height="50" width="50" onClick="HighLightTR39(this);" <?php echo $c[39];?>><input type="checkbox" name="s39" value="39" <?php echo $s[39]; ?>><br><font color="#FFFFFF">39</font></td>
				<td height="50" width="50" onClick="HighLightTR38(this);" <?php echo $c[38];?>><input type="checkbox" name="s38" value="38" <?php echo $s[38]; ?>><br><font color="#FFFFFF">38</font></td>
				<td height="50" width="50" onClick="HighLightTR37(this);" <?php echo $c[37];?>><input type="checkbox" name="s37" value="37" <?php echo $s[37]; ?>><br><font color="#FFFFFF">37</font></td>
			</tr>
		</table>
		<table border="1" style="font-size:10px;" width="300">
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR36(this);" <?php echo $c[36];?>><input type="checkbox" name="s36" value="36" <?php echo $s[36]; ?>><br><font color="#FFFFFF">36</font></td>
				<td height="50" width="50" onClick="HighLightTR35(this);" <?php echo $c[35];?>><input type="checkbox" name="s35" value="35" <?php echo $s[35]; ?>><br><font color="#FFFFFF">35</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR34(this);" <?php echo $c[34];?>><input type="checkbox" name="s34" value="34" <?php echo $s[34]; ?>><br><font color="#FFFFFF">34</font></td>
				<td height="50" width="50" onClick="HighLightTR33(this);" <?php echo $c[33];?>><input type="checkbox" name="s33" value="33" <?php echo $s[33]; ?>><br><font color="#FFFFFF">33</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR32(this);" <?php echo $c[32];?>><input type="checkbox" name="s32" value="32" <?php echo $s[32]; ?>><br><font color="#FFFFFF">32</font></td>
				<td height="50" width="50" onClick="HighLightTR31(this);" <?php echo $c[31];?>><input type="checkbox" name="s31" value="31" <?php echo $s[31]; ?>><br><font color="#FFFFFF">31</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR30(this);" <?php echo $c[30];?>><input type="checkbox" name="s30" value="30" <?php echo $s[30]; ?>><br><font color="#FFFFFF">30</font></td>
				<td height="50" width="50" onClick="HighLightTR29(this);" <?php echo $c[29];?>><input type="checkbox" name="s29" value="29" <?php echo $s[29]; ?>><br><font color="#FFFFFF">29</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR28(this);" <?php echo $c[28];?>><input type="checkbox" name="s28" value="28" <?php echo $s[28]; ?>><br><font color="#FFFFFF">28</font></td>
				<td height="50" width="50" onClick="HighLightTR27(this);" <?php echo $c[27];?>><input type="checkbox" name="s27" value="27" <?php echo $s[27]; ?>><br><font color="#FFFFFF">27</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR26(this);" <?php echo $c[26];?>><input type="checkbox" name="s26" value="26" <?php echo $s[26]; ?>><br><font color="#FFFFFF">26</font></td>
				<td height="50" width="50" onClick="HighLightTR25(this);" <?php echo $c[25];?>><input type="checkbox" name="s25" value="25" <?php echo $s[25]; ?>><br><font color="#FFFFFF">25</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR24(this);" <?php echo $c[24];?>><input type="checkbox" name="s24" value="24" <?php echo $s[24]; ?>><br><font color="#FFFFFF">24</font></td>
				<td height="50" width="50" onClick="HighLightTR23(this);" <?php echo $c[23];?>><input type="checkbox" name="s23" value="23" <?php echo $s[23]; ?>><br><font color="#FFFFFF">23</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR22(this);" <?php echo $c[22];?>><input type="checkbox" name="s22" value="22" <?php echo $s[22]; ?>><br><font color="#FFFFFF">22</font></td>
				<td height="50" width="50" onClick="HighLightTR21(this);" <?php echo $c[21];?>><input type="checkbox" name="s21" value="21" <?php echo $s[21]; ?>><br><font color="#FFFFFF">21</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR20(this);" <?php echo $c[20];?>><input type="checkbox" name="s20" value="20" <?php echo $s[20]; ?>><br><font color="#FFFFFF">20</font></td>
				<td height="50" width="50" onClick="HighLightTR19(this);" <?php echo $c[19];?>><input type="checkbox" name="s19" value="19" <?php echo $s[19]; ?>><br><font color="#FFFFFF">19</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR18(this);" <?php echo $c[18];?>><input type="checkbox" name="s18" value="18" <?php echo $s[18]; ?>><br><font color="#FFFFFF">18</font></td>
				<td height="50" width="50" onClick="HighLightTR17(this);" <?php echo $c[17];?>><input type="checkbox" name="s17" value="17" <?php echo $s[17]; ?>><br><font color="#FFFFFF">17</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR16(this);" <?php echo $c[16];?>><input type="checkbox" name="s16" value="16" <?php echo $s[16]; ?>><br><font color="#FFFFFF">16</font></td>
				<td height="50" width="50" onClick="HighLightTR15(this);" <?php echo $c[15];?>><input type="checkbox" name="s15" value="15" <?php echo $s[15]; ?>><br><font color="#FFFFFF">15</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR14(this);" <?php echo $c[14];?>><input type="checkbox" name="s14" value="14" <?php echo $s[14]; ?>><br><font color="#FFFFFF">14</font></td>
				<td height="50" width="50" onClick="HighLightTR13(this);" <?php echo $c[13];?>><input type="checkbox" name="s13" value="13" <?php echo $s[13]; ?>><br><font color="#FFFFFF">13</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR12(this);" <?php echo $c[12];?>><input type="checkbox" name="s12" value="12" <?php echo $s[12]; ?>><br><font color="#FFFFFF">12</font></td>
				<td height="50" width="50" onClick="HighLightTR11(this);" <?php echo $c[11];?>><input type="checkbox" name="s11" value="11" <?php echo $s[11]; ?>><br><font color="#FFFFFF">11</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR10(this);" <?php echo $c[10];?>><input type="checkbox" name="s10" value="10" <?php echo $s[10]; ?>><br><font color="#FFFFFF">10</font></td>
				<td height="50" width="50" onClick="HighLightTR9(this);" <?php echo $c[9];?>><input type="checkbox" name="s9" value="9" <?php echo $s[9]; ?>><br><font color="#FFFFFF">09</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR8(this);" <?php echo $c[8];?>><input type="checkbox" name="s8" value="8" <?php echo $s[8]; ?>><br><font color="#FFFFFF">08</font></td>
				<td height="50" width="50" onClick="HighLightTR7(this);" <?php echo $c[7];?>><input type="checkbox" name="s7" value="7" <?php echo $s[7]; ?>><br><font color="#FFFFFF">07</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR6(this);" <?php echo $c[6];?>><input type="checkbox" name="s6" value="6" <?php echo $s[6]; ?>><br><font color="#FFFFFF">06</font></td>
				<td height="50" width="50" onClick="HighLightTR5(this);" <?php echo $c[5];?>><input type="checkbox" name="s5" value="5" <?php echo $s[5]; ?>><br><font color="#FFFFFF">05</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" onClick="HighLightTR4(this);" <?php echo $c[4];?>><input type="checkbox" name="s4" value="4" <?php echo $s[4]; ?>><br><font color="#FFFFFF">04</font></td>
				<td height="50" width="50" onClick="HighLightTR3(this);" <?php echo $c[3];?>><input type="checkbox" name="s3" value="3" <?php echo $s[3]; ?>><br><font color="#FFFFFF">03</font></td>
				<td height="50" width="100">&nbsp;</td>
				<td height="50" width="50" onClick="HighLightTR2(this);" <?php echo $c[2];?>><input type="checkbox" name="s2" value="2" <?php echo $s[2]; ?>><br><font color="#FFFFFF">02</font></td>
				<td height="50" width="50" onClick="HighLightTR1(this);" <?php echo $c[1];?>><input type="checkbox" name="s1" value="1" <?php echo $s[1]; ?>><br><font color="#FFFFFF">01</font></td>
			</tr>
			<tr align="center">
				<td height="50" width="50" colspan="4">&nbsp;</td>
				<td height="50" width="50"><font color="#FFFFFF">Driver</font></td>
			</tr>
			
		</table>
		<table border="1" style="font-size:10px;" width="300">
			<td height="50" width="50"><font color="red">Front</font></td>
			</table>
		
	</div>
	<br><br>
	<center><input type="submit" name="submit" value="Reserve">
	<input type="submit" name="cancel" value="Cancel"></center>
</form>
<?php } ?>

</div>

	</body>
</html>

Recommended Answers

All 3 Replies

Could you please post just the relevant bit of code. It is very hard to wade through 10 page lengths of code.

To optimise your code for readablity, and avoiding boredom of scrolling down - like i experienced. Replace your js functions such as

function HighLightTR39(el, rowName){
  if (document.myform.s39.checked == true) {
      el.bgColor=bgcolorSelected;
  } else {
    el.bgColor=bgcolorNotSelected;
  }
}

using one function similar to the one below which passes the changing field s1, s2 ... sn, as a variable sName. This or something similar will eliminate exactly 300 lines of code.

function HighLightTR(el, sName){
  if (document.myform.sName.checked == true) {
      el.bgColor=bgcolorSelected;
  } else {
    el.bgColor=bgcolorNotSelected;
  }
}

To optimise your code for readablity, and avoiding boredom of scrolling down - like i experienced. Replace your js functions such as

function HighLightTR39(el, rowName){
  if (document.myform.s39.checked == true) {
      el.bgColor=bgcolorSelected;
  } else {
    el.bgColor=bgcolorNotSelected;
  }
}

using one function similar to the one below which passes the changing field s1, s2 ... sn, as a variable sName. This or something similar will eliminate exactly 300 lines of code.

function HighLightTR(el, sName){
  if (document.myform.sName.checked == true) {
      el.bgColor=bgcolorSelected;
  } else {
    el.bgColor=bgcolorNotSelected;
  }
}

Probably need:

function HighLightTR(el, sName){
  if (document.myform[sName].checked == true) {
      el.bgColor=bgcolorSelected;
  } else {
    el.bgColor=bgcolorNotSelected;
  }
}

document.myform.sName.checked would treat sName as the literal string "sName".
IE:

document.myform['sName'].checked

but you want:

document.myform[sName].checked

where it is the property name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.