So I tried to : 1) toggle the background color og a DIV element by the click of a button 2) change the image source (not toggle) by the click of a button.
The code is pretty simple to me and by right, I dont see a problem with it, but for some reason just doesnt work!! please help... any advise would be highly appreciated mates.
<!Doctype HTML>
<HTML>
<head>
<script>
function changeimage()
{ x = document.getElementById("image");
x.src="e:\PHOTOS\garfield-coffee.jpg";
x.alt="e:-\PHOTOS\garfield-coffee.jpg"; // the new image doesnt load, but if I specify an "alt", it seems to work.
}
function changeDivColor()
{ x = document.getElementById("main_container")
if(x.style.backgroundColor=="#3B7AF0") // the if thens just dont work. Simply changing color one time does.
{ x.style.backgroundColor="#dfedf0"; }
else
{ x.style.backgroundColor=="#3B7AF0"; }
}
</script>
</head>
<body>
<div id="main_container" style="background-color:#3B7AF0;width:1800px;height:1800px;font-size:10pt">
<img id="image" src="e:\photos\garf2.jpg" width:40px height:40px></img>
<div id="Scriptarea"> <!-- Javascript stuff -->
<form>
<input type="button" onclick="changeimage()" value="click here to change garfield"></input>
<input type="button" onclick="changeDivColor()" value="Change DIV color"></input>
</form>
</div> <!-- Javascript stuff -->
</div>
</body>