Reputation: 3
essentially i have this div
<div id="trafficcam" style="text-align:center;display:none;">
<img id="image" src="http://131940.qld.gov.au/DMR.Controls/WebCams/DisplayImage.ashx?FilePath=Gold_Coast/GrandisSth.jpg" alt="Sorry, no traffic cam is available">
and I'd like to change the src of the file so that when a button is pressed the image changes. I can't really hide it and have it show a different one because this div is for the traffic cams, and i'd rather have it a bit more compact.
the button to execute it is
<input type=button value="cam" onclick="selectCam()">
which i have tested and it works
the function it calls is:
function selectCam()
{
alert(document.getElementById("image"))
document.getElementbyId("image").src="http://i.imgur.com/zP9kTfe.jpg";
}
which seems to not change anything on the page when the button is pressed
Upvotes: 0
Views: 1779
Reputation: 1176
Also watch out for the insidious getElementByID
(the "D" shouldn't be capitalised).
Upvotes: 0
Reputation: 6069
There is no method getElementbyId
, it's called getElementById
.
Check out the error console, there should be something like
Unhandled Error: 'document.getElementbyId' is not a function
Upvotes: 2