Hen cam motion on website page

We have two camera on our backyard hens. They are set to refresh every 3 seconds. One shows "outside" view. One shows "nest boxes". We have gotten the "outside" to refresh but there seems to be a conflict in the javascript, not allowing the "nest boxes" to refresh. We are total amateurs at code, so patience is required.

You can see the website at backyardhencam.com.
Who is Participating?
actually I just noticed you have multiple refresh rates, you only need one var for it so in my code delete
var refreshrate2=3;                 //SECONDS BETWEEN REFRESH

and change
setTimeout('refresh()', refreshrate2*1000);} to setTimeout('refresh()', refreshrate*1000);}
Copy and paste my code in, i tested it and it's working, if you add more cameras to make them all refresh just change the refresh function to handle the new camera.
<script language="javascript"> 
var refreshrate=3;                 //SECONDS BETWEEN REFRESH
var image="http://hencam1.viewnetcam.com:5002/SnapshotJPEG?Resolution=640x480&amp;Quality=Standard";     //IMAGE NAME
var imgheight=480;                   //IMAGE HEIGHT
var imgwidth=640;                 //IMAGE WIDTH
document.write('<IMG SRC="'+image+'" ALT="Chicken Coup" NAME="pic" ID="pic" WIDTH="'+imgwidth+'" HEIGHT="'+imgheight+'" BORDER="0">');

<h4>If screen is dark, shhhhhhh&#8230;hens are sleeping.</h4>
<script language="javascript"> 
var refreshrate2=3;                 //SECONDS BETWEEN REFRESH
var image2="http://hencam2.viewnetcam.com:5003/SnapshotJPEG?Resolution=320x240&amp;Quality=Standard";     //IMAGE NAME
var imgheight2=480;                   //IMAGE HEIGHT
var imgwidth2=640;                 //IMAGE WIDTH
document.write('<IMG SRC="'+image2+'" ALT="Nestboxes" NAME="pic2" ID="pic2" WIDTH="'+imgwidth2+'" HEIGHT="'+imgheight2+'" BORDER="0">');

function refresh(){
document.images["pic"].src=image+"?"+new Date();
document.images["pic2"].src=image2+"?"+new Date();
setTimeout('refresh()', refreshrate2*1000);}



Open in new window

LeeOlAuthor Commented:
Can't wait to see if this works. Thank you!

It will take me a little time to do this. I'm very inexperienced at this code thing. Will let you know as soon as I try it.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LeeOlAuthor Commented:
Wow! I got my son to paste your code in for me and it works beautifully! Can't thank you enough for your expertise!
LeeOlAuthor Commented:
I can't believe that something I've worked on for two months was solved in less than an hour! Amazing!
Your very welcome!
BTW, you may want to check into adding Google Analytics to your website. It will tell you where your users are coming from, how many hits your getting a day, how you stack up against other websites and a whole slew of other useful data. Not to mention it's free, you just drop a bit of code they give you onto the end of your webpage and your ready. Usually updates every 24hrs.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.