I am working on a dynamic bingo game that randomly generates the number in each bingo square and when you click on a square it will change color. This I have accomplished. I created a table and within each TD I have the following code:
<td onclick="javascript:this.style.background = '#00ff00';"
id="B1" class="bingo1"><script>document.write(patty[0]);</script></td>
When the page is loaded each square (td) will have a variable that is initially set to 0 (var B1 = 0;). When you click in the square the variable is increased to 1, but I have no idea how to do this. I thought that maybe it could be done with the onclick event or maybe it would detect when the background color changes. But, as I said, I have no idea how to do either of these. Any and all help would be greatly appreciated. Thanks!
- Each square will have a different id, such as B2, B3, B4, B5, I1, I2, etc.
Take care and have a great day....
ciao, john.
ids? And you really should move away from in-line JavaScript and separate your model and behaviour (if only for future maintainability).