I’m trying to make a quick html scoreboard. I’ve got it working with a single score, but I’m at a loss as to how to make it work with multiple scores on the same page.
To count up, click on the second zero (ones column). To count down, click on the first zero (tens column).
Also, if I’m doing something entirely boneheaded, just let me know.
[CODE]
<style type=”text/css”>
/*<![CDATA[*/
<!–
a {text-decoration:none; font-size: 150pt}
a:link {color: blue;}
a:visited {color: blue;}
a:hover {color: blue;}
a:active {color: blue;}//–>
/*]]>*/
</style>
<script type=”text/javascript”>
//<![CDATA[
var x=0;
function up() {
++x;
y = x.toString();
if (y < 10) {
y = “0”+y;
}
document.getElementById(‘tens’).innerHTML = y.substr(0,1);
document.getElementById(‘ones’).innerHTML = y.substr(1);
}
function down() {
–x;
y = x.toString();
if (y < 10) {
y = “0”+y;
}
document.getElementById(‘tens’).innerHTML = y.substr(0,1);
document.getElementById(‘ones’).innerHTML = y.substr(1);
}
//]]>
</script>
I was calling the function via two links on the page:
[CODE]<a href=”#” id=”tens” onmousedown=”down()” name=”tens”>0</a><a href=”#” id=”ones” onmousedown=”up()” name=”ones”>0</a>