Hey guys, I'm new to the forums, so if i post anything wrong let me know.
I'm trying to use links to hide all the images, and show just ones from a certain category. I've used the img name attribute to group them and tried to do a function that shows only one img.
here's the script...
<script language="javascript">
function showone(x) {
document.getElementByName('a').style.display='none';
document.getElementByName('b').style.display='none';
document.getElementByName('c').style.display='none';
document.getElementByName(x).style.display='block';
}
</script>
and the code...
<a href="#" onClick="showone('a'); ">show CAT. A</a><br>
<a href="#" onClick="showone('b'); ">show CAT. B</a><br>
<a href="#" onClick="showone('c'); ">show CAT. C</a><br>
<a href="#">show all cats</a><br>
<br>
<img name="a" src="imgs/a1.jpg" /><br>
<img name="b" src="imgs/b1.jpg" /><br>
<img name="a" src="imgs/a2.jpg" /><br>
<img name="a" src="imgs/a3.jpg" /><br>
<img name="b" src="imgs/b2.jpg" /><br>
<img name="c" src="imgs/c1.jpg" />
Here's what it looks like...
http://mattfalcone.com/tests/showhide.html
except the links don't work like they should, and I can't figure out why.
I'm an idiot with javascript, so if feel free to make fun of me, and if anyone knows how to get this simple function to work, please let me know and I'de appreciate it.