Hi... I'm new... help? :P
Hey there folks, nice to meet ya.
I decided to finally get off my butt and learn JavaScript, or at least understand what I'm doing for apparently small scripts. I have a slight issue with what I'm working on right now.
The idea here is for a map. I'll be using the map as the base image, and then dropping transparent .GIFs over top. This is so peopel can see set boundary lines for viewing from a selection list. Basically they hit the button, the GIF turns on, hit it again it goes off.
Now I did some hunting for useable code, but found nothing that was applicable. Too many linear slideshows or onMouseover/onMouseout rollovers, and I dont want that, I want onClick effects.
Here is what I have;
<html>
<head>
<script>
on=false;
function changeImg(imgName) {
document.images[imgName].src=imgName+((o n)?'_off':'_on')+'.bmp';
on=!on
return false;
}
</script>
</head>
<body>
<img src="alert_off.bmp" name="alert" width="60" height="52" alt="ON/OFF" border="0">
<input type=submit onClick="return changeImg("alert")">
</body>
</html>
I guess the good news should be that no errors come up when I press the button to change the graphic. Nothing happens, but no errors pop up. if the code is along the lines of
document.images["alert"].src='alert_'+((o n)?'off':'on')+'.bmp';
it works fine, but that's only for one image. I dont know how many images could/will become involved with this, and I dont want to be bogged down with line after line of functions, so a single function passing an argument would be fantastic.
If anyone can point out where I have gone wrong, then I would be very grateful.
I decided to finally get off my butt and learn JavaScript, or at least understand what I'm doing for apparently small scripts. I have a slight issue with what I'm working on right now.
The idea here is for a map. I'll be using the map as the base image, and then dropping transparent .GIFs over top. This is so peopel can see set boundary lines for viewing from a selection list. Basically they hit the button, the GIF turns on, hit it again it goes off.
Now I did some hunting for useable code, but found nothing that was applicable. Too many linear slideshows or onMouseover/onMouseout rollovers, and I dont want that, I want onClick effects.
Here is what I have;
<html>
<head>
<script>
on=false;
function changeImg(imgName) {
document.images[imgName].src=imgName+((o
on=!on
return false;
}
</script>
</head>
<body>
<img src="alert_off.bmp" name="alert" width="60" height="52" alt="ON/OFF" border="0">
<input type=submit onClick="return changeImg("alert")">
</body>
</html>
I guess the good news should be that no errors come up when I press the button to change the graphic. Nothing happens, but no errors pop up. if the code is along the lines of
document.images["alert"].src='alert_'+((o
it works fine, but that's only for one image. I dont know how many images could/will become involved with this, and I dont want to be bogged down with line after line of functions, so a single function passing an argument would be fantastic.
If anyone can point out where I have gone wrong, then I would be very grateful.
