Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7702943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:20:44+00:00 2026-05-31T23:20:44+00:00

I am working on a dynamic bingo game that randomly generates the number in

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:20:45+00:00Added an answer on May 31, 2026 at 11:20 pm

    I would just have a two dimensional array, (5×5) all set to zeros (aside the free space, which is set to 1), and then the individual cells are buttons to change some array value to 1.

    like so:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Bingo</title>
    <style>
    #card {width:510px; margin-right:auto; margin-left:auto; position:relative; }
    .top {border: thin #000 solid; float:left; width:100px; height:20px; text-align:center;}
    .cell {border: thin #000 solid; float:left; width:100px; height:60px;text-align:center;padding-top:40px;}
    .on {border: thin #000 solid; float:left; width:100px; height:60px; background-color:#0F0;text-align:center;padding-top:40px;}
    .win {border: thin #000 solid; float:left; width:100px; height:60px; background-color:#F00;text-align:center;padding-top:40px;}
    </style>
    </head>
    
    <body>
    <div id="card"><div class="top">B</div><div class="top">I</div><div class="top">N</div><div class="top">G</div><div class="top">O</div></div>
    </body>
    <script type="text/javascript">
    var score=new Array();
    var existingNumbers=new Array();
    var r,c;
    for(r=0;r<5;r++){
        for(c=0;c<5;c++){
            score[r]=Array();
            score[r][c]=0;
            if((c==2)&&(r==2)){
                score[r][c]=1;
                document.getElementById('card').innerHTML+='<div id="cell'+r+c+'" class="on">FREE</div>';
            }
            else{
                document.getElementById('card').innerHTML+='<div id="cell'+r+c+'" class="cell" onclick="tap('+r+','+c+');">'+number(c)+'</div>';    
            }
        }
        document.body.innerHTML+='<br/>';
    }
    
    function number(col){
        var num=Math.ceil(Math.random()*15)+(15*col);
        while(existingNumbers.indexOf(num)!=-1){
            num=Math.ceil(Math.random()*15)+(15*col);
        }
        existingNumbers.push(num);
        return num;
    }
    
    function tap(r,c){
        document.getElementById('cell'+r+c).className="on";
        score[r][c]=1;
        winTest();
    }
    
    function winTest(){
        //there has got to be a more concise way of doing this, but right now it's just for function
        var winner=false;
        r1=score[0][0]+score[1][0]+score[2][0]+score[3][0]+score[4][0];
        r2=score[0][1]+score[1][1]+score[2][1]+score[3][1]+score[4][1];
        r3=score[0][2]+score[1][2]+1+score[3][2]+score[4][2];
        r4=score[0][3]+score[1][3]+score[2][3]+score[3][3]+score[4][3];
        r5=score[0][4]+score[1][4]+score[2][4]+score[3][4]+score[4][4];
        c1=score[0][0]+score[0][1]+score[0][2]+score[0][3]+score[0][4];
        c2=score[1][0]+score[1][1]+score[1][2]+score[1][3]+score[1][4];
        c3=score[2][0]+score[2][1]+1+score[2][3]+score[2][4];
        c4=score[3][0]+score[3][1]+score[3][2]+score[3][3]+score[3][4];
        c5=score[4][0]+score[4][1]+score[4][2]+score[4][3]+score[4][4];
        d1=score[0][0]+score[1][1]+1+score[3][3]+score[4][4];
        d2=score[0][4]+score[1][3]+1+score[3][1]+score[4][0];
        if(r1==5){
            document.getElementById('cell00').className="win";
            document.getElementById('cell10').className="win";
            document.getElementById('cell20').className="win";
            document.getElementById('cell30').className="win";
            document.getElementById('cell40').className="win";
            winner=true;
        }
        if(r2==5){
            document.getElementById('cell01').className="win";
            document.getElementById('cell11').className="win";
            document.getElementById('cell21').className="win";
            document.getElementById('cell31').className="win";
            document.getElementById('cell41').className="win";
            winner=true;
        }
        if(r3==5){
            document.getElementById('cell02').className="win";
            document.getElementById('cell12').className="win";
            document.getElementById('cell22').className="win";
            document.getElementById('cell32').className="win";
            document.getElementById('cell42').className="win";
            winner=true;
        }
        if(r4==5){
            document.getElementById('cell03').className="win";
            document.getElementById('cell13').className="win";
            document.getElementById('cell23').className="win";
            document.getElementById('cell33').className="win";
            document.getElementById('cell43').className="win";
            winner=true;
        }
        if(r5==5){
            document.getElementById('cell04').className="win";
            document.getElementById('cell14').className="win";
            document.getElementById('cell24').className="win";
            document.getElementById('cell34').className="win";
            document.getElementById('cell44').className="win";
            winner=true;
        }
        if(c1==5){
            document.getElementById('cell00').className="win";
            document.getElementById('cell01').className="win";
            document.getElementById('cell02').className="win";
            document.getElementById('cell03').className="win";
            document.getElementById('cell04').className="win";
            winner=true;
        }
        if(c2==5){
            document.getElementById('cell10').className="win";
            document.getElementById('cell11').className="win";
            document.getElementById('cell12').className="win";
            document.getElementById('cell13').className="win";
            document.getElementById('cell14').className="win";
            winner=true;
        }
        if(c3==5){
            document.getElementById('cell20').className="win";
            document.getElementById('cell21').className="win";
            document.getElementById('cell22').className="win";
            document.getElementById('cell23').className="win";
            document.getElementById('cell24').className="win";
            winner=true;
        }
        if(c4==5){
            document.getElementById('cell30').className="win";
            document.getElementById('cell31').className="win";
            document.getElementById('cell32').className="win";
            document.getElementById('cell33').className="win";
            document.getElementById('cell34').className="win";
            winner=true;
        }
        if(c5==5){
            document.getElementById('cell40').className="win";
            document.getElementById('cell41').className="win";
            document.getElementById('cell42').className="win";
            document.getElementById('cell43').className="win";
            document.getElementById('cell44').className="win";
            winner=true;
        }
        if(d1==5){
            document.getElementById('cell00').className="win";
            document.getElementById('cell11').className="win";
            document.getElementById('cell22').className="win";
            document.getElementById('cell33').className="win";
            document.getElementById('cell44').className="win";
            winner=true;
        }
        if(d2==5){
            document.getElementById('cell04').className="win";
            document.getElementById('cell13').className="win";
            document.getElementById('cell22').className="win";
            document.getElementById('cell31').className="win";
            document.getElementById('cell40').className="win";
            winner=true;
        }
        if(winner){
            alert('You WIN!!');
        }
    }
    </script>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're working in a Dynamic Data project that will handle entities coming from two
Working with a dynamic page that 1. generates a list of files in the
I'm working on a PHP dynamic web page that has a <textarea> element that
I'm working on a stored proc that executes some dynamic sql. Here's the example
Has anyone seen this error when working with a PHP application out of dynamic
I have a working dynamic TableLayout that holds user data. Clicking an Add Event
I'm working on a dynamic pivot query on a table that contains: OID -
Using this wiki I have a dynamic dropdownlist working just fine. Instead of the
I am working on a project involving Dynamic Programming and am struck on this
I'm currently working with a part of my application that uses Dynamic Web User

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.