I keep getting the error that document.safetyForm.elements.AO.style is null or not an object.
Can anyone shed some light as to why I am getting this?
The code is as follows (sorry it's so long, I wanted to include all the code):
Thanks,
John Axsom
Can anyone shed some light as to why I am getting this?
The code is as follows (sorry it's so long, I wanted to include all the code):
Code:
<?php
//Ensure this file is being included by a parent file
defined( '_VALID_SAFETY' ) or die( 'Direct Access to this location is not allowed.' );
function Life_MgmtForm( &$row, $option, $fire_date_tmp, $fire_date_tmp2, $grey_date_tmp, $pink_date_tmp, $loc_acute, $loc_ccc, $loc_offsite ) {
?>
<script language="JavaScript">
<!--
function showLocation(loc) {
document.safetyForm.elements['LA'].style.display = (loc == '0') ? '':'None';
document.safetyForm.elements['LC'].style.display = (loc == '1') ? '':'None';
[COLOR=red] document.safetyForm.elements['AO'].style.display = (loc == '0') ? '':'None';[/color]
}
function checkform() {
if (!document.safetyForm.fac_name[0].checked && !document.safetyForm.fac_name[1].checked)
{
alert("Please select which facility this report is for.");
document.safetyForm.fac_name[0].focus();
return false;
}
if (!document.safetyForm.fire_curr[0].checked && !document.safetyForm.fire_curr[1].checked)
{
alert("Are all fire drills current?\nPlease select Yes or No.");
document.safetyForm.fire_curr[0].focus();
return false;
}
if (document.safetyForm.fire_hour.value == "NA")
{
alert("Please enter the time of the last fire drill.");
document.safetyForm.fire_hour.focus();
return false;
}
if (document.safetyForm.fire_shift.value == "")
{
alert("Please select which shift the fire drill was conducted on.");
document.safetyForm.fire_shift.focus();
return false;
}
if (document.safetyForm.fac_name[0].checked)
{
if (document.safetyForm.fire_loc_acute.value == "")
{
alert("Please select the location of the last fire drill.");
document.safetyForm.fire_loc_acute.focus();
return false;
}
}
if (document.safetyForm.fac_name[1].checked)
{
if (document.safetyForm.fire_loc_ccc.value == "")
{
alert("Please select the location of the last fire drill.");
document.safetyForm.fire_loc_ccc.focus();
return false;
}
}
if (document.safetyForm.fire_nar.value == "What was the staff's reaction to the fire drill performed above? Comments?" || document.safetyForm.fire_nar.value == "")
{
alert("Please explain the staff's reaction to the fire drill performed above along with any additional comments.\nIf none, please type None.");
document.safetyForm.fire_nar.focus();
return false;
}
if (document.safetyForm.fac_name[0].checked)
{
if (!document.safetyForm.grey_curr[0].checked && !document.safetyForm.grey_curr[1].checked)
{
alert("Has code grey been tested?\nPlease select Yes or No.");
document.safetyForm.grey_curr[0].focus();
return false;
}
if (document.safetyForm.grey_hour.value == "NA")
{
alert("Please enter the time when code grey was last tested.");
document.safetyForm.grey_hour.focus();
return false;
}
if (document.safetyForm.grey_nar.value == "What was the staff's reaction to the code grey test performed above? Comments?" || document.safetyForm.grey_nar.value == "")
{
alert("Please explain the staff's reaction to the code grey test performed above along with any additional comments.\nIf none, please type None.");
document.safetyForm.grey_nar.focus();
return false;
}
if (!document.safetyForm.pink_curr[0].checked && !document.safetyForm.pink_curr[1].checked)
{
alert("Has code pink been tested?\nPlease select Yes or No.");
document.safetyForm.pink_curr[0].focus();
return false;
}
if (document.safetyForm.pink_hour.value == "NA")
{
alert("Please enter the time when code pink was last tested.");
document.safetyForm.pink_hour.focus();
return false;
}
if (document.safetyForm.pink_nar.value == "What was the staff's reaction to the code pink test performed above? Comments?" || document.safetyForm.pink_nar.value == "")
{
alert("Please explain the staff's reaction to the code pink test performed above along with any additional comments.\nIf none, please type None.");
document.safetyForm.pink_nar.focus();
return false;
}
}
}
//-->
</script>
<form name="safetyForm" method="post" action="index.php" onSubmit="return checkform()">
<table border="1" cellspacing="0" width="75%" align="center" class="larger">
<tr>
<td bgcolor="#003399" width="100%" align="center"><font class="label1" color="white"><b><? echo $row->id ? 'Edit -':'Add -'; ?> Life Safety Management Report For <? echo date("F Y", mktime(0,0,0,date("m")-1,1,date("Y"))); ?></b></font></td>
</tr>
<tr>
<td><table border="1" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td>Report for: <input name="fac_name" type="radio" value="Acute"<? if ($row->fac_name=='Acute') { echo " checked"; } ?> onClick="return showLocation('0')"> Acute <input name="fac_name" type="radio" value="CCC"<? if ($row->fac_name=='CCC') { echo " checked"; } ?> onClick="return showLocation('1')"> CCC</td>
</tr>
<tr>
<td>Are all Fire Drills current? <input name="fire_curr" type="radio" value="1"<? if($row->fire_curr=='1') { echo " checked"; } ?>> Yes <input name="fire_curr" type="radio" value="0"<? if($row->fire_curr=='0') { echo " checked"; } ?>> No</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4">The last fire drill was conducted on:</td>
</tr>
<tr>
<td align="center">Date</td>
<td align="center">Time</td>
<td align="center">Shift</td>
<td align="center">Location</td>
</tr>
<tr>
<td align="center">
<select name="fire_month">
<?php
for ($month=1;$month <=12;$month++) {
echo "<option value='$month'";
if ($row->id) {
if ($fire_date_tmp[1]==$month) {
echo " SELECTED";
}
} else {
if (date("n")==$month) {
echo " SELECTED";
}
}
echo ">$month</option>\n";
}
?>
</select> /
<select name="fire_day">
<?php
for ($day=1;$day <=31;$day++) {
echo "<option";
if ($row->id) {
if ($fire_date_tmp[2]==$day) {
echo " SELECTED";
}
} else {
if (date("j")==$day) {
echo " SELECTED";
}
}
echo ">$day</option>\n";
}
?>
</select> /
<select name="fire_year">
<?php
$currentYear=date("Y");
for ($year=($currentYear-1);$year <=($currentYear+2);$year++) {
echo "<option";
if ($row->id) {
if ($fire_date_tmp[0]==$year) {
echo " SELECTED";
}
} else {
if (date("Y")==$year) {
echo " SELECTED";
}
}
echo ">$year</option>\n";
}
?>
</select>
</td>
<td align="center">
<select name="fire_hour">
<option value="NA">NA</option>
<?php
for ($N=1;$N<=12;$N++) {
echo "<option";
if ($row->id) {
if ($fire_date_tmp[3]==$N) {
echo " SELECTED";
}
}
echo ">$N</option>";
}
?>
</select> :
<select name="fire_min">
<?php
for ($N=0;$N<=55;$N=$N+15) {
echo "<option";
if ($row->id) {
if ($fire_date_tmp[4]==$N) {
echo " SELECTED";
}
}
$E=($N<10) ? "0".$N:$N;echo ">$E</option>";
}
?>
</select>
<select name="fire_ap">
<option<? if($fire_date_tmp[5]=='AM') { echo " SELECTED"; } ?>>AM</option>
<option<? if($fire_date_tmp[5]=='PM') { echo " SELECTED"; } ?>>PM</option>
</select>
</td>
<td align="center">
<select name="fire_shift">
<option value=""<? if(!$row->id) { echo " selected"; } ?>></option>
<option value="1"<? if($row->shift=='1') { echo " selected"; } ?>>1</option>
<option value="2"<? if($row->shift=='2') { echo " selected"; } ?>>2</option>
<option value="3"<? if($row->shift=='3') { echo " selected"; } ?>>3</option>
</select>
</td>
<td align="center">
<select name="fire_loc_acute" id="LA"<? if($row->fac_name=='Acute') { echo " style=\"display:;\""; } else { echo " style=\"display:none;\""; } ?>>
<option value=""<? if(!$row->id) { echo " selected"; } ?>></option>
<?
$num_results = mysql_num_rows($loc_acute);
for ($i=0; $i<$num_results; $i++) {
$loca = mysql_fetch_object($loc_acute);
echo "<option value=".$loca->id;
if ($row->fac_name=='Acute') {
if ($row->fire_loc==$loca->id) {
echo " SELECTED";
}
}
echo ">" . $loca->fire_loc . "</option>\n";
}
?>
</select>
<select name="fire_loc_ccc" id="LC"<? if($row->fac_name=='CCC') { echo " style=\"display:;\""; } else { echo " style=\"display:none;\""; } ?>>
<option value=""<? if(!$row->id) { echo " selected"; } ?>></option>
<?
$num_results = mysql_num_rows($loc_ccc);
for ($i=0; $i<$num_results; $i++) {
$locb = mysql_fetch_object($loc_ccc);
echo "<option value=" . $locb->id;
if ($row->fac_name=='CCC') {
if ($row->fire_loc==$locb->id) {
echo " SELECTED";
}
}
echo ">" . $locb->fire_loc . "</option>\n";
}
?>
</select>
</td>
</tr></table>
</td>
</tr>
<tr>
<td>Comments:<br><textarea name="fire_nar" cols="75" rows="10" onFocus="fire_nar.select()"><? echo $row->fire_nar ? stripslashes($row->fire_nar):'What was the staff\'s reaction to the fire drill performed above? Comments?'; ?></textarea></td>
</tr></table>
</td>
</tr>
</table>
[COLOR=red]<div id="AO"<? if($row->fac_name=='Acute') { echo " style=\"display:;\""; } else { echo " style=\"display:none;\""; } ?>>[/color]
<table border="1" cellspacing="0" width="75%" align="center" class="larger">
<tr>
<td bgcolor="#003399" width="100%" align="center"><font color="white"><b>Code Grey</b></font></td>
</tr>
<tr>
<td><table border="1" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td>Has Code Grey been tested? <input name="grey_curr" type="radio" value="1"<? if($row->grey_curr=='1') { echo " checked"; } ?>> Yes <input name="grey_curr" type="radio" value="0"<? if($row->grey_curr=='0') { echo " checked"; } ?>> No</td>
</tr>
<tr>
<td><table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Code Grey tested on:</td>
</tr>
<tr>
<td align="center">Date</td>
<td align="center">Time</td>
</tr>
<tr>
<td align="center">
<select name="grey_month">
<?php
for ($month=1;$month <=12;$month++) {
echo "<option value='$month'";
if ($row->id) {
if ($grey_date_tmp[1]==$month) {
echo " SELECTED";
}
} else {
if (date("n")==$month) {
echo " SELECTED";
}
}
echo ">$month</option>\n";
}
?>
</select> /
<select name="grey_day">
<?php
for ($day=1;$day <=31;$day++) {
echo "<option";
if ($row->id) {
if ($grey_date_tmp[2]==$day) {
echo " SELECTED";
}
} else {
if (date("j")==$day) {
echo " SELECTED";
}
}
echo ">$day</option>\n";
}
?>
</select> /
<select name="grey_year">
<?php
$currentYear=date("Y");
for ($year=($currentYear-1);$year <=($currentYear+2);$year++) {
echo "<option";
if ($row->id) {
if ($grey_date_tmp[0]==$year) {
echo " SELECTED";
}
} else {
if (date("Y")==$year) {
echo " SELECTED";
}
}
echo ">$year</option>\n";
}
?>
</select>
</td>
<td align="center">
<select name="grey_hour">
<option value="NA">NA</option>
<?php
for ($N=1;$N<=12;$N++) {
echo "<option";
if ($row->id) {
if ($grey_date_tmp[3]==$N) {
echo " SELECTED";
}
}
echo ">$N</option>";
}
?>
</select> :
<select name="grey_min">
<?php
for ($N=0;$N<=55;$N=$N+15) {
echo "<option";
if ($row->id) {
if ($grey_date_tmp[4]==$N) {
echo " SELECTED";
}
}
$E=($N<10) ? "0".$N:$N;echo ">$E</option>";
}
?>
</select>
<select name="grey_ap">
<option<? if($grey_date_tmp[5]=='AM') { echo " SELECTED"; } ?>>AM</option>
<option<? if($grey_date_tmp[5]=='AM') { echo " SELECTED"; } ?>>PM</option>
</select>
</td>
</tr></table>
</td>
</tr>
<tr>
<td>Comments:<br><textarea name="grey_nar" cols="75" rows="10" onFocus="grey_nar.select()"><? echo $row->grey_nar ? stripslashes($row->grey_nar):'What was the staff\'s reaction to the code grey test performed above? Comments?'; ?></textarea></td>
</tr>
<tr>
<td bgcolor="#003399" width="100%" align="center"><font color="white"><b>Code Pink</b></font></td>
</tr>
<tr>
<td>Has Code Pink been tested? <input name="pink_curr" type="radio" value="1"<? if($row->pink_curr=='1') { echo " checked"; } ?>> Yes <input name="pink_curr" type="radio" value="0"<? if($row->pink_curr=='0') { echo " checked"; } ?>> No</td>
</tr>
<tr>
<td><table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Code Pink tested on:</td>
</tr>
<tr>
<td align="center">Date</td>
<td align="center">Time</td>
</tr>
<tr>
<td align="center">
<select name="pink_month">
<?php
for ($month=1;$month <=12;$month++) {
echo "<option value='$month'";
if ($row->id) {
if ($pink_date_tmp[1]==$month) {
echo " SELECTED";
}
} else {
if (date("n")==$month) {
echo " SELECTED";
}
}
echo ">$month</option>\n";
}
?>
</select> /
<select name="pink_day">
<?php
for ($day=1;$day <=31;$day++) {
echo "<option";
if ($row->id) {
if ($pink_date_tmp[2]==$day) {
echo " SELECTED";
}
} else {
if (date("j")==$day) {
echo " SELECTED";
}
}
echo ">$day</option>\n";
}
?>
</select> /
<select name="pink_year">
<?php
$currentYear=date("Y");
for ($year=($currentYear-1);$year <=($currentYear+2);$year++) {
echo "<option";
if ($row->id) {
if ($pink_date_tmp[0]==$year) {
echo " SELECTED";
}
} else {
if (date("Y")==$year) {
echo " SELECTED";
}
}
echo ">$year</option>\n";
}
?>
</select>
</td>
<td align="center">
<select name="pink_hour">
<option value="NA">NA</option>
<?php
for ($N=1;$N<=12;$N++) {
echo "<option";
if ($row->id) {
if ($pink_date_tmp[3]==$N) {
echo " SELECTED";
}
}
echo ">$N</option>";
}
?>
</select> :
<select name="pink_min">
<?php
for ($N=0;$N<=55;$N=$N+15) {
echo "<option";
if ($row->id) {
if ($pink_date_tmp[4]==$N) {
echo " SELECTED";
}
}
$E=($N<10) ? "0".$N:$N;echo ">$E</option>";
}
?>
</select>
<select name="pink_ap">
<option<? if($pink_date_tmp[5]=='AM') { echo " SELECTED"; } ?>>AM</option>
<option<? if($pink_date_tmp[5]=='AM') { echo " SELECTED"; } ?>>PM</option>
</select>
</td>
</tr></table>
</td>
</tr>
<tr>
<td>Comments:<br><textarea name="pink_nar" cols="75" rows="10" onFocus="pink_nar.select()"><? echo $row->pink_nar ? stripslashes($row->pink_nar):'What was the staff\'s reaction to the code pink test performed above? Comments?'; ?></textarea></td>
</tr></table>
</td>
</tr>
</table>
</div>
<br>
<table border="0" cellspacing="0" width="75%" align="center">
<tr>
<td align="center"><input name="" type="submit" value="Submit"> <input name="btnback" type="button" value="Back" onClick="history.go(-1)"></td>
</tr>
</table>
<input name="id" type="hidden" value="<? echo $row->id ? $row->id:'0'; ?>">
<input name="rptdate" type="hidden" value="<? echo $row->rptdate ? $row->rptdate:date("Y-m-d H:i:s"); ?>">
<input name="month" type="hidden" value="<? echo $row->month ? $row->month:date("F Y", mktime(0,0,0,date("m")-1,1,date("Y"))); ?>">
<input name="option" type="hidden" value="<? echo $option; ?>">
<input name="task" type="hidden" value="save">
</form>
<?PHP
}
?>
Thanks,
John Axsom