lundi 30 mars 2015

If statement based on time of day to document write an .js from the web

`We have a webpage that displays the wait time of an ER. The java script will change the content based on the time of day. If the time is from 10am to 10pm the http://ift.tt/1bJNOhd should display the wait time. If not then say closed. I have tried everything i know which is not much first time coding javascript and i have tried google searching even looked in innerhtml. If anyone could please help i would appericate it


The problem is that i cannot get the .js to run in the if statement. I have tried with out document write. i have tried this format





document.write('<script src="http://ift.tt/1bJNOhd"><\/script>');





<script language="JavaScript">
var objDate = new Date();
var hours = objDate.getHours();
if(hours >= 10 && hours <= 22){
document.write('<src="http://ift.tt/1bJNO0q;');
}
else
{
document.write('CLOSED');
}

</script>



full code found here





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb" xml:lang="en"
lang="en">
<head>
<title>Shannon Medical Center | San Angelo, Texas | Shannon
Medical Center</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<meta name="Distribution" content="Global" />
<meta name="Author" content="Ashley Aguilar" />
<meta http-equiv="refresh" content="300" />
<link rel="stylesheet" href="style.css"
type="text/css" />
</head>
<body>
<div id="container">
<div id="content"><!-- CONTENT START -->
<p style="text-align: center;"><img src="UCT.png" /></p>
<p
style="text-align: center; font-family: tahoma,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 25px; line-height: normal; font-size-adjust: none; font-stretch: normal;">If
the wait time is more than 45 minutes, you can call ahead.</p>
<h1><img src="UCN.png" /></h1>
<table>
<tbody>
<tr>
<td width="410">
<blockquote>
<script language="JavaScript">
var objDate = new Date();
var hours = objDate.getHours();
if(hours >= 10 && hours <= 22){
document.write('<src="http://ift.tt/1bJNO0q;');
}
else
{
document.write('CLOSED');
}

</script>
</blockquote>
</td>
<td width="300">
<p
style="font-family: tahoma,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 18px; line-height: normal; font-size-adjust: none; font-stretch: normal;">32626
N. Bryant<br />
San Angelo, TX 76903<br />
No Appointment Required<br />
325.481.2271</p>
</td>
<td width="300">
<p
style="font-family: tahoma,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 20px; line-height: normal; font-size-adjust: none; font-stretch: normal;">Hours
Open<br />
7am - 8pm Daily</p>
</td>
</tr>
</tbody>
</table>
<h2><img src="UCS.png" /></h2>
<table>
<tbody>
<tr>
<td width="410">
<blockquote>
<script
src="http://ift.tt/1bJNOhd"></script>
mins.
</blockquote>
</td>
<td width="300">
<p
style="font-family: tahoma,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 18px; line-height: normal; font-size-adjust: none; font-stretch: normal;">3502
Knickerbocker Rd.<br />
San Angelo, TX 76904<br />
No Appointment Required<br />
325.481.2222</p>
</td>
<td width="300">
<p
style="font-family: tahoma,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 20px; line-height: normal; font-size-adjust: none; font-stretch: normal;">Hours
Open<br />
7am - 10pm Daily</p>
</td>
</tr>
</tbody>
</table>
<h2><img src="UCW.png" /></h2>
<table>
<tbody>
<tr>
<td width="410">
<blockquote>
<script
src="http://ift.tt/1bJNOxr"></script>
mins.
</blockquote>
</td>
<td width="300">
<p
style="font-family: tahoma,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 18px; line-height: normal; font-size-adjust: none; font-stretch: normal;">4251
Sunset Dr.<br />
San Angelo, TX 76904<br />
No Appointment Required<br />
325.481.2226</p>
</td>
<td width="300">
<p
style="font-family: tahoma,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 20px; line-height: normal; font-size-adjust: none; font-stretch: normal;">Hours
Open<br />
7am - 10pm Daily</p>
</td>
</tr>
</tbody>
</table>
<!-- CONTENT END -->
</div>
<div><!-- CONTAINER END -->
</div>
</div>
</body>
</html>



Aucun commentaire:

Enregistrer un commentaire