java click counter in html
i have a site with several links on it and each link has a box next to it. the box is white to start with. on roll over it changes to red and when the link is clicked i want the box to turn blue but retain the red roll over feature.
i have got so far with the code;
<html>
<head>
<title>java test</title>
<script language="JavaScript" type="text/JavaScript">
<!--
var news = 0
if (document.images)
{
newson=new Image();
newson.src="red.gif";
if (news == 0){
newsoff=new Image();
newsoff.src="white.gif";
}
else{
newsoff=new Image();
newsoff.src="blue.gif";
}
}
function imgon(imgName){if (document.images){document[imgName].src=eval(imgName+"on.src");}}
function imgoff(imgName){if (document.images){document[imgName].src=eval(imgName+"off.src");}}
//-->
</script>
</head>
<body>
<a href="#" onMouseOver="imgon('news')" onMouseOut="imgoff('news')"><img
border="0" src="white.gif" name="news"> link</a>
</body>
</html>
so i need to change the variable 'news' to 1 when the link is clicked.
if you can tell me how to this, that would be great.
if you know a better way of achieving the same result please let me know.
also i was thinking of putting the java script in an external file like a style sheet. does any one have any experience doing this? will it mean that my rollover images are less likly to work?
cheers for any help
steve

