This is the original script that I used to show/hide my column:
================================================== ==========
<html>
<head>
<script>
function show_hide_column(col_no, do_show) {
var stl;
if (do_show) stl = 'block'
else stl = 'none';
var tbl = document.getElementById('table_hide');
var rows = tbl.getElementsByTagName('tr');
for (var row=0; row<rows.length;row++) {
var cels = rows[row].getElementsByTagName('td')
cels[col_no].style.display=stl;
}
}
</script>
</head>
<body>
<form>
<img src="Images/link.gif" width="10" height="10" onClick='javascript
:show_hide_column(1, true);'>Show "Pod Status"<br>
<img src="Images/link.gif" width="10" height="10" onClick='javascript
:show_hide_column(1, false);'>Hide "Pod Status"<br>
</form>
<table id='table_hide' border=1>
<tr><td> 1</td><td> one</td><td> un</td><td> eins</td></tr>
<tr><td> 2</td><td> two</td><td> deux</td><td> zwei</td></tr>
<tr><td> 3</td><td> three</td><td> trois</td><td> drei</td></tr>
<tr><td> 4</td><td> four</td><td>quattre</td><td> vier</td></tr>
<tr><td> 5</td><td> five</td><td> cinq</td><td>fünf</td></tr>
<tr><td> 6</td><td> six</td><td> six</td><td> sechs</td></tr>
</table>
================================================== ==========
This is my code where I've inserted part of the above script but I encountered the error: "'style' is null or not an object" at the line "cels[col_no].style.display=stl;"
Thanks in advance for your kind help.
================================================== ==========
<?php
include("start.php");
include("function.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>2.2 Pre-Inspection</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="preinsp_form" method="GET">
<table width="96%">
<tr>
<td height="44" colspan="2" align="center" class="header">Smif Pod & Smart Tag Tracking System</td>
</tr>
<tr>
<td height="23" colspan="2" align="center" class="main_table_header">2.2 Pre-Inspection</td>
</tr>
<tr>
<td valign="top">
<?php include("menu.htm");?>
</td>
<td width="80%" height="485" valign="top">
<table border="1">
<!--
<?php $rowlength=pg_num_rows($rs_latest_inc);
echo 'rows.length='.$rowlength.'<br>';?>
-->
<script type="text/javascript">
function show_hide_column(col_no, do_show)
{
var stl;
if (do_show) stl = 'block'
else stl = 'none';
var tbl = document.getElementById('table_hide');
var rows = tbl.getElementsByTagName('tr');
for (var row=0; row<rows.length;row++)
{
var cels = rows[row].getElementsByTagName('td')
cels[col_no].style.display=stl;
}
}
</script>
<script>
// var rowlength=<?php $rowlength;?>;
// document.write('this is the row length in
js=');
// document.write(rowlength);
</script>
<tr>
<td>
<img src="Images/link.gif" width="10" height="10" onClick="javascript
:show_hide_column(1, true)">Show "Pod Status"<br>
<img src="Images/link.gif" width="10" height="10" onClick="javascript
:show_hide_column(1, false);">Hide "Pod Status"<br>
</td>
</tr>
</table>
<table id="table_hide" width="888" border="1">
<tr>* Pod details: Pod S/N, Cass S/N, Podbase S/N, Tag S/N</tr>
<tr><td height="40"> </td>
<td><strong>Pod Details</strong></td>
<td><strong>Pod Defect</strong></td>
<td><strong>Cassette Status</strong></td>
<td><strong>Podbase Status</strong></td>
<td><strong>Smart Tag Status</strong></td>
<td><strong>Updated Time</strong></td>
<td><strong>Updated By</strong></td>
<td><strong>Sent Time</strong></td>
<td><strong>Sent By</strong></td>
<td><strong>Received Time</strong></td>
<td><strong>Received By</strong></td>
<td><strong>Remarks</strong></td>
</tr>
<?php
//Displays all the latest records in the pod database where status="Pre-Inspection"
$sql_latest_inc="SELECT * FROM pod WHERE pod_status='Pre-Inspection'";
$rs_latest_inc=pg_query($db_link, $sql_latest_inc) or die(pg_result_error());
//Checkbox arrays
$cb = 0;
//Start of loop to display all available records
while ($row_latest_inc=pg_fetch_assoc($rs_latest_inc))
{
?>
<tr>
<td>
<input name="checkbox<?php echo $cb;?>" type="checkbox" id="checkbox<?php echo $cb; ?>" value="<?php echo $row_latest_inc['pod_sn_time']; ?>">
</td>
<td>
<?php echo $row_latest_inc['pod_sn'];?>, <?php echo $row_latest_inc['cass_sn'];?>, <?php echo $row_latest_inc['podbase_sn'];?>, <?php echo $row_latest_inc['tag_sn'];?>
</td>
<input type="hidden" name="pod_status" value="<?php echo $row_latest_inc['pod_status'];?>">
<td>
<?php include ("pod_defect.php");?>
<td>
<div>
<p align="left"><a href="javascript
:void(0);" onClick="window.open('cass_defect.php?pod_sn_time= <?php echo $row_latest_inc['pod_sn_time'];?>','pop_up','resizable=yes,scrollbars=yes,height =800,width=450')" >Cassette Defect Details <img src="Images/link.gif" width="10" height="10"></a></p>
<p align="left"> </p>
</div>
<div>Proceed?
<input name="cass_stat<?php echo $cb;?>" type="checkbox" id="cass_stat<?php echo $cb;?>" value="<?php echo "Proceed";?>">
</div>
</td>
<td>
<div>
<p align="left"><a href="javascript
:void(0);" onClick="window.open('pb_defect.php?pod_sn_time=<? php echo $row_latest_inc['pod_sn_time'];?>','pop_up','resizable=yes,scrollbars=yes,height =800,width=450')" >Podbase Defect Details <img src="Images/link.gif" width="10" height="10"></a></p>
<p align="left"> </p>
</div>
<div>Proceed?
<input name="pb_stat<?php echo $cb;?>" type="checkbox" id="pb_stat<?php echo $cb;?>" value="<?php echo "Proceed";?>">
</div>
</td>
<td>
<div>
<p align="left"><a href="javascript
:void(0);" onClick="window.open('tag_defect.php?pod_sn_time=< ?php echo $row_latest_inc['pod_sn_time'];?>','pop_up','resizable=yes,scrollbars=yes,height =800,width=450')" >Smart Tag Defect Details <img src="Images/link.gif" width="10" height="10"></a></p>
<p align="left"> </p>
</div>
<div>Proceed?
<input name="tag_stat<?php echo $cb;?>" type="checkbox" id="tag_stat<?php echo $cb;?>" value="<?php echo "Proceed";?>">
</div>
</td>
<td><?php echo $row_latest_inc['pod_update_time'];?></td>
<td><?php echo $row_latest_inc['pod_update_by'];?></td>
<td><?php echo $row_latest_inc['pod_sent_time'];?></td>
<td><?php echo $row_latest_inc['pod_sent_by'];?></td>
<td><?php echo $row_latest_inc['pod_recv_time'];?></td>
<td><?php echo $row_latest_inc['pod_recv_by'];?></td>
<td><?php echo $row_latest_inc['pod_remarks'];?></td>
<?php
$cb++;
}
?>
</tr>
</table>
<table width="100%">
<tr>
<td>
<input type="submit" class="button" name="Proceed" value="Proceed" id="Proceed">
</td>
</tr>
</table></td>
</tr>
</form>
<?php
// Change pod_status of current pod_sn_time to '-Pre-Inspection' and add a duplicate record (but different pod_sn_time) with pod_status='Pre-Clean' or 'Disposition'
// If Proceed button active, start this
$count=pg_num_rows($rs_latest_inc);
if(isset($_GET['Proceed']))
{
for($i=0;$i<$count;$i++)
{
$proceed_id = 'checkbox'.$i;
$pod_stat = 'pod_stat'.$i;
$cass_stat = 'cass_stat'.$i;
$pb_stat = 'pb_stat'.$i;
$tag_stat = 'tag_stat'.$i;
$sql_chkbox1 = "UPDATE pod SET pod_status='-Pre-Inspection', pod_sn_time='-".$_GET[$proceed_id]."' WHERE pod_sn_time='".$_GET[$proceed_id]."'";
$rs_chkbox1 = pg_query($db_link, $sql_chkbox1) or die(pg_result_error());
echo 'sql_chkbox1='.$sql_chkbox1.'<br>';
$sql_chkbox2 = "SELECT * FROM pod WHERE pod_sn_time='-".$_GET[$proceed_id]."'";
$rs_chkbox2 = pg_query($db_link, $sql_chkbox2) or die(pg_result_error());
$row_chkbox2 = pg_fetch_assoc($rs_chkbox2);
echo 'sql_chkbox2='.$sql_chkbox2.'<br>';
//only execute this if pod_sn NOT null
if(($row_chkbox2['pod_sn']!="")&&($_GET[$pod_stat]=="Proceed")&&($_GET[$cass_stat]=="Proceed")&&($_GET[$pb_stat]=="Proceed")&&($_GET[$tag_stat]=="Proceed"))
{
$sql_chkbox = "INSERT INTO pod(pod_sn_time, pod_sn, tag_holder_sn, cass_sn, podbase_sn, tag_sn, pod_chd_type, pod_brand, pod_mat_code, pod_cat, pod_status, pod_clean, pod_update_time, pod_update_by, pod_sent_time, pod_sent_by, pod_recv_time, pod_recv_by, pod_request_time, pod_request_by, pod_issue_time, pod_issue_by, pod_defect, cass_defect, pb_defect, tag_defect, pod_clean_tool, pod_remarks) VALUES (
'".$row_chkbox2['pod_sn'].$pod_update_time."',
'".$row_chkbox2['pod_sn']."',
'".$row_chkbox2['tag_holder_sn']."',
'".$row_chkbox2['cass_sn']."',
'".$row_chkbox2['podbase_sn']."',
'".$row_chkbox2['tag_sn']."',
'".$row_chkbox2['pod_chd_type']."',
'".$row_chkbox2['pod_brand']."',
'".$row_chkbox2['pod_mat_code']."',
'".$row_chkbox2['pod_cat']."',
'Pre-Clean',
'".$row_chkbox2['pod_clean']."',
'".$pod_update_time."',
'".$pod_update_by."',
'".$row_chkbox2['pod_sent_time']."',
'".$row_chkbox2['pod_sent_by']."',
'".$row_chkbox2['pod_recv_time']."',
'".$row_chkbox2['pod_recv_by']."',
'".$row_chkbox2['pod_request_time']."',
'".$row_chkbox2['pod_request_by']."',
'".$row_chkbox2['pod_issue_time']."',
'".$row_chkbox2['pod_issue_by']."',
'".$row_chkbox2['pod_defect']."',
'".$row_chkbox2['cass_defect']."',
'".$row_chkbox2['pb_defect']."',
'".$row_chkbox2['tag_defect']."',
'".$row_chkbox2['pod_clean_tool']."',
'".$row_chkbox2['pod_remarks']."'
)";
$rs_chkbox = pg_query($db_link, $sql_chkbox) or die(pg_result_error());
echo 'sql_chkbox='.$sql_chkbox.'<br>';
pg_free_result($rs_chkbox);
}
else if(($row_chkbox2['pod_sn']!="")&&(($_GET[$pod_stat]=="")||($_GET[$cass_stat]=="")||($_GET[$pb_stat]=="")||($_GET[$tag_stat]=="")))
{
$sql_chkbox = "INSERT INTO pod(pod_sn_time, pod_sn, tag_holder_sn, cass_sn, podbase_sn, tag_sn, pod_chd_type, pod_brand, pod_mat_code, pod_cat, pod_status, pod_clean, pod_update_time, pod_update_by, pod_sent_time, pod_sent_by, pod_recv_time, pod_recv_by, pod_request_time, pod_request_by, pod_issue_time, pod_issue_by, pod_defect, cass_defect, pb_defect, tag_defect, pod_clean_tool, pod_remarks) VALUES (
'".$row_chkbox2['pod_sn'].$pod_update_time."',
'".$row_chkbox2['pod_sn']."',
'".$row_chkbox2['tag_holder_sn']."',
'".$row_chkbox2['cass_sn']."',
'".$row_chkbox2['podbase_sn']."',
'".$row_chkbox2['tag_sn']."',
'".$row_chkbox2['pod_chd_type']."',
'".$row_chkbox2['pod_brand']."',
'".$row_chkbox2['pod_mat_code']."',
'".$row_chkbox2['pod_cat']."',
'Disposition',
'".$row_chkbox2['pod_clean']."',
'".$pod_update_time."',
'".$pod_update_by."',
'".$row_chkbox2['pod_sent_time']."',
'".$row_chkbox2['pod_sent_by']."',
'".$row_chkbox2['pod_recv_time']."',
'".$row_chkbox2['pod_recv_by']."',
'".$row_chkbox2['pod_request_time']."',
'".$row_chkbox2['pod_request_by']."',
'".$row_chkbox2['pod_issue_time']."',
'".$row_chkbox2['pod_issue_by']."',
'".$row_chkbox2['pod_defect']."',
'".$row_chkbox2['cass_defect']."',
'".$row_chkbox2['pb_defect']."',
'".$row_chkbox2['tag_defect']."',
'".$row_chkbox2['pod_clean_tool']."',
'".$row_chkbox2['pod_remarks']."'
)";
$rs_chkbox = pg_query($db_link, $sql_chkbox) or die(pg_result_error());
echo 'sql_chkbox='.$sql_chkbox.'<br>';
pg_free_result($rs_chkbox);
}
}
//if successful redirect to preinsp.php
if($rs_chkbox1)
{
echo "<meta http-equiv=\"refresh\" content=\"0;URL=preinsp.php\">";
}
}
?>
<tr>
<td colspan="2"><div class="bottomtext" align="center"><?php echo $footer; ?></div></td>
</tr>
</body>
</html>
================================================== ==========