Adding up values from random arrray

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 853 Views - Last Post: 06 November 2013 - 08:55 PM

#16 EdNolan  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 241
  • Joined: 22-September 13

Re: Adding up values from random arrray

Posted 02 November 2013 - 09:49 AM

That's still not working for me. I'm getting this error, Missing ; before statement. I get this error at line 104. Here's the entire script. Everything is working except the innerHTML. Any ideas?
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
    <head>
        <title>My Game</title>
        <style>
            #tblGuess img {
                width: 36px; height: 48px;
            }
        </style>
    </head>
    <body>
        
<table>
      <tr>
      <td><div id="result1"></div><td><div id="result2"></div></td><td><div id="result3"></div></td>
      </tr>
</table>

<script type="text/javascript">

var imgArray = ["aceclub.png", "aceheart.png", "acespade.png", "acediam.png", "twoclub.png", "twoheart.png", "twospade.png", "twodiam.png",
             "threeclub.png", "threeheart.png", "threespade.png", "threediam.png", "fourclub.png", "fourheart.png", "fourspade.png", "fourdiam.png", 
             "fiveclub.png", "fiveheart.png", "fivespade.png", "fivediam.png", "sixclub.png", "sixheart.png", "sixspade.png", "sixdiam.png", 
             "sevenclub.png", "sevenheart.png", "sevenspade.png", "sevendiam.png", "eightclub.png", "eightheart.png", "eightspade.png", "eightdiam.png", 
             "nineclub.png", "nineheart.png", "ninespade.png", "ninediam.png", "tenclub.png", "tenheart.png", "tenspade.png", "tendiam.png",
             "jackclub.png", "jackheart.png", "jackspade.png", "jackdiam.png", "queenclub.png", "queenheart.png", "queenspade.png", "queendiam.png",
             "kingclub.png", "kingheart.png", "kingspade.png", "kingdiam.png"];
           //make a clone of imgArray

var basePath = "///C:/Users/Dads/Desktop/game/";  // This is the file location of all the card images.

function imgRandom() {          // This is the main program.
var clone = imgArray.slice(0);  // We are copying imgArray and will use clone as our working array.
for (i = 0; i < 9; i++) {       // We need our first nine images of the game, this is the start of our loop.
        var i, rand, image;     // These are just some of the variables used in the program
        var shownImages = [];   // I made an empty array that will store each image picked, serves as a record.
var randIndex = Math.floor(Math.random() * clone.length);  // We randomly pick from clone array here.
var rand = clone[randIndex];    // Our image is now known as rand and it's location in the clone array is known as randIndex
        image = new Image();    // or new Image(144, 192); // Here wa are telling the computer we are going to show a new image.
        image.src = basePath + rand;  // Now we have to tell the program to take the random image now called rand from the folder.
        shownImages.push(rand);  // Now I am writing(push) a record of the image(rand). Im putting(push) it in the shownImages array
//        console.log(shownImages[0])
        image.width = 54;        // This sets the images display size that players see on their screens.
        image.height = 72;       // This sets the images display size that players see on their screens.
        document.body.appendChild(image);  // This actually puts the images onto the page as a new image.
clone.splice(randIndex,1);      // This will cut out the image/index from the clone array to avoid duplicates.
}

// ---------  Start Comparing For Odds Here --------------------------------------
var group1 = intersect(shownImages, ["aceclub.png", "aceheart.png", "acespade.png", "acediam.png"]).length;
var group2 = intersect(shownImages, ["twoclub.png", "twoheart.png", "twospade.png", "twodiam.png"]).length;
var group3 = intersect(shownImages, ["threeclub.png", "threeheart.png", "threespade.png", "threediam.png"]).length;
var group4 = intersect(shownImages, ["fourclub.png", "fourheart.png", "fourspade.png", "fourdiam.png"]).length;
var group5 = intersect(shownImages, ["fiveclub.png", "fiveheart.png", "fivespade.png", "fivediam.png"]).length;
var group6 = intersect(shownImages, ["sixclub.png", "sixheart.png", "sixspade.png", "sixdiam.png"]).length;
var group7 = intersect(shownImages, ["sevenclub.png", "sevenheart.png", "sevenspade.png", "sevendiam.png"]).length;
var group8 = intersect(shownImages, ["eightclub.png", "eightheart.png", "eightspade.png", "eightdiam.png"]).length;
var group9 = intersect(shownImages, ["nineclub.png", "nineheart.png", "ninespade.png", "ninediam.png"]).length;
var group10 = intersect(shownImages, ["tenclub.png", "tenheart.png", "tenspade.png", "tendiam.png"]).length;
var group11 = intersect(shownImages, ["jackclub.png", "jackheart.png", "jackspade.png", "jackdiam.png"]).length;
var group12 = intersect(shownImages, ["queenclub.png", "queenheart.png", "queenspade.png", "queendiam.png"]).length;
var group13 = intersect(shownImages, ["kingclub.png", "kingheart.png", "kingspade.png", "kingdiam.png"]).length;
//            --------------- Start Comparing Odds Here -----------------
//var oddsAftNinthPick = ["10:1", "14:1", "21:1", "43:1", "0:0"];
//                var odds = oddsAftNinthPick[0];
//console.log(group1);
//            --------------- Finish Comparing Odds Here ----------------

picAgain()
// I NEED TO DISPLAY THE ODDS FOR EACH TURN OF PLAY NOW !!!
function picAgain(limit) {
    var count = 0;
    function liveCount() {
        count += 1
        if (count <= 28) {    // There are a total of 28 turns of play
var randIndex = Math.floor(Math.random() * clone.length);
var rand = clone[randIndex];
        image = new Image();    // or new Image(144, 192);
        image.src = basePath + rand;
        shownImages.push(rand);
//        console.log(shownImages[0])
        image.width = 54;
        image.height = 72;
        document.body.appendChild(image);
clone.splice(randIndex,1);
        } else{
            clearInterval();
        }
    }
    var counter = setInterval(liveCount, 3000);
}
}  // This ends imgRandom

imgRandom()
compareOdds()
function compareOdds() {

             if (group1 == 0) {
               document.getElementById("result1").innerHTML ="10:1";
                                  }

            else if (group1 == 1) {
                document.getElementById("result1").innerHTML ="14:1";
                                  }

            else if (group1 == 2) {
                document.getElementById("result1").innerHTML ="21:1";
                                  }

            else if (group1 == 3) {
                document.getElementById("result1")innerHTML ="43:1";
                                  }

            else if (group1 == 4) {
                document.getElementById("result1").innerHTML ="0:0";
                                  }

}
        </script>
    </body>
</html>


This post has been edited by EdNolan: 02 November 2013 - 01:54 PM

Was This Post Helpful? 0
  • +
  • -

#17 EdNolan  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 241
  • Joined: 22-September 13

Re: Adding up values from random arrray

Posted 02 November 2013 - 08:01 PM

After testing and testing and testing, lol, I believe there is something missing in this code.
var group1 = intersect(shownImages, ["aceclub.png", "aceheart.png", "acespade.png", "acediam.png"]).length;
var group2 = intersect(shownImages, ["twoclub.png", "twoheart.png", "twospade.png", "twodiam.png"]).length;
var group3 = intersect(shownImages, ["threeclub.png", "threeheart.png", "threespade.png", "threediam.png"]).length;
var group4 = intersect(shownImages, ["fourclub.png", "fourheart.png", "fourspade.png", "fourdiam.png"]).length;
var group5 = intersect(shownImages, ["fiveclub.png", "fiveheart.png", "fivespade.png", "fivediam.png"]).length;
var group6 = intersect(shownImages, ["sixclub.png", "sixheart.png", "sixspade.png", "sixdiam.png"]).length;
var group7 = intersect(shownImages, ["sevenclub.png", "sevenheart.png", "sevenspade.png", "sevendiam.png"]).length;
var group8 = intersect(shownImages, ["eightclub.png", "eightheart.png", "eightspade.png", "eightdiam.png"]).length;
var group9 = intersect(shownImages, ["nineclub.png", "nineheart.png", "ninespade.png", "ninediam.png"]).length;
var group10 = intersect(shownImages, ["tenclub.png", "tenheart.png", "tenspade.png", "tendiam.png"]).length;
var group11 = intersect(shownImages, ["jackclub.png", "jackheart.png", "jackspade.png", "jackdiam.png"]).length;
var group12 = intersect(shownImages, ["queenclub.png", "queenheart.png", "queenspade.png", "queendiam.png"]).length;
var group13 = intersect(shownImages, ["kingclub.png", "kingheart.png", "kingspade.png", "kingdiam.png"]).length;




I am now turning my focus to that code. No matter where I insert those lines, my code either doesn't work, or I only get the first pic.

Here is the code that works without inserting the above. But I need that code above to work.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
    <head>
        <title>Title and DOCTYPE are Required</title>
        <style>
            #tblGuess img {
                width: 36px; height: 48px;
            }
        </style>
    </head>
    <body>
        
<table>
      <tr>
      <td><ul id="myList"></ul></td>
      </tr>
</table>

<script type="text/javascript">

var imgArray = ["aceclub.png", "aceheart.png", "acespade.png", "acediam.png", "twoclub.png", "twoheart.png", "twospade.png", "twodiam.png",
             "threeclub.png", "threeheart.png", "threespade.png", "threediam.png", "fourclub.png", "fourheart.png", "fourspade.png", "fourdiam.png", 
             "fiveclub.png", "fiveheart.png", "fivespade.png", "fivediam.png", "sixclub.png", "sixheart.png", "sixspade.png", "sixdiam.png", 
             "sevenclub.png", "sevenheart.png", "sevenspade.png", "sevendiam.png", "eightclub.png", "eightheart.png", "eightspade.png", "eightdiam.png", 
             "nineclub.png", "nineheart.png", "ninespade.png", "ninediam.png", "tenclub.png", "tenheart.png", "tenspade.png", "tendiam.png",
             "jackclub.png", "jackheart.png", "jackspade.png", "jackdiam.png", "queenclub.png", "queenheart.png", "queenspade.png", "queendiam.png",
             "kingclub.png", "kingheart.png", "kingspade.png", "kingdiam.png"];
           //make a clone of imgArray

var basePath = "///C:/Users/Dads/Desktop/game/";  // This is the file location of all the card images.

function imgRandom() {          // This is the main program.
var clone = imgArray.slice(0);  // We are copying imgArray and will use clone as our working array.
for (i = 0; i < 9; i++) {       // We need our first nine images of the game, this is the start of our loop.
        var i, rand, image;     // These are just some of the variables used in the program
        var shownImages = [];   // I made an empty array that will store each image picked, serves as a record.
var randIndex = Math.floor(Math.random() * clone.length);  // We randomly pick from clone array here.
var rand = clone[randIndex];    // Our image is now known as rand and it's location in the clone array is known as randIndex
        image = new Image();    // or new Image(144, 192); // Here wa are telling the computer we are going to show a new image.
        image.src = basePath + rand;  // Now we have to tell the program to take the random image now called rand from the folder.
        shownImages.push(rand);  // Now I am writing(push) a record of the image(rand). Im putting(push) it in the shownImages array
//        console.log(shownImages[0])
        image.width = 54;        // This sets the images display size that players see on their screens.
        image.height = 72;       // This sets the images display size that players see on their screens.
        document.body.appendChild(image);  // This actually puts the images onto the page as a new image.
clone.splice(randIndex,1);      // This will cut out the image/index from the clone array to avoid duplicates.


// ---------  Start Getting Odds Here --------------------------------------


function compareOdds()
{
//var group1 = Math.floor(Math.random() * 5) + 1        The code even works when I allow this line to be read

       if (group1 == 0) {
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  10:1  -");
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
} 
  else if (group1 == 1) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  14:1  -");
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
}
  else if (group1 == 2) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  21:1  -");
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
}
  else if (group1 == 3) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  43:1  -");
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
}
  else if (group1 == 4) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  0:0  -");
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
}

}

//            --------------- Finish Getting Odds Here ----------------
compareOdds()

}



picAgain()
// I NEED TO DISPLAY THE ODDS FOR EACH TURN OF PLAY NOW !!!
function picAgain(limit) {
    var count = 0;
    function liveCount() {
        count += 1
        if (count <= 28) {    // There are a total of 28 turns of play
var randIndex = Math.floor(Math.random() * clone.length);
var rand = clone[randIndex];
        image = new Image();    // or new Image(144, 192);
        image.src = basePath + rand;
        shownImages.push(rand);
//        console.log(shownImages[0])
        image.width = 54;
        image.height = 72;
        document.body.appendChild(image);
clone.splice(randIndex,1);
        } else{
            clearInterval();
        }
    }
    var counter = setInterval(liveCount, 3000);
}
}  // This ends imgRandom

imgRandom()

        </script>
    </body>
</html>



When I remove it Any ideas?
Was This Post Helpful? 0
  • +
  • -

#18 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,028
  • Joined: 08-June 10

Re: Adding up values from random arrray

Posted 03 November 2013 - 02:47 AM

Quote

After testing and testing and testing, lol, I believe there is something missing in this code.

have you checked what values your globals contain?

besides that, shownImages is local to imgRandom(), so your whole comparing code works on an undefined variable.

the proverb that globals are evil does not come from no-where.
Was This Post Helpful? 1
  • +
  • -

#19 EdNolan  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 241
  • Joined: 22-September 13

Re: Adding up values from random arrray

Posted 03 November 2013 - 07:31 AM

View PostDormilich, on 03 November 2013 - 02:47 AM, said:

have you checked what values your globals contain?
besides that, shownImages is local to imgRandom(), so your whole comparing code works on an undefined variable.
the proverb that globals are evil does not come from no-where.

1). I think I tried checking but will make a better effort too check values.
2). I'm glad you noticed the local issue. I felt from your previous suggestions about imgRandom that I at least had to put this new code within as well. But since I cloned imgArray, I'm now thinking I would need to clone shownImages to get groups to function with compare. You're making me think. Lots to learn.
3). So about the evil globals, I believe your pointing to shownImages? I did some research. I see I would have to wrap everything into one function. Is my thinking correct? Maybe I should count or compare as shownImages is being populated to avoid this mess, do you agree?

This post has been edited by EdNolan: 03 November 2013 - 07:56 AM

Was This Post Helpful? 0
  • +
  • -

#20 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,028
  • Joined: 08-June 10

Re: Adding up values from random arrray

Posted 03 November 2013 - 12:59 PM

3) your thinking is not correct. whether you wrap all your code into a function or not does not make any differences for the scope chains involved (except for one more level).

the general way to avoid globals is:
- an appropriate application design
- the use of objects (or whatever construct is available in the language of choice) that represent a functional unit*.



* - see also your other thread, post #20 & #42. exactly this is the reason why I used an object there.
Was This Post Helpful? 1
  • +
  • -

#21 EdNolan  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 241
  • Joined: 22-September 13

Re: Adding up values from random arrray

Posted 04 November 2013 - 08:07 PM

I finally have something working !!! However, nothing seemed to work when I would use innerHTML so I found something that does when I changed the innerHTML to appendChild. At this moment it produces a line of results across the screen and I only want it in one place on the screen, and for it to overwrite itself. This is a <ul> tag I know, I don't want line indent either.<ol> won't work either. For whatever reason i couldn't get <div> to work. Any ideas how to do away with LINE or LINE INDENT and just go with a single placement that overwrites itself? If not, can you give me code that works since I can't seem to do it right? This works at least, so I am a little happy. Help? Or is there a way to leave this as is and just have the id overwrite itself without placing a new odds value next to each other? Can you code it to removeChild and then appendChild for me, please? I don't know how to do it but think it can be done.


<td><ul id="aceOdds"></ul></td>

function figureOdds() {
         if (( rand == "aceclub.png") || ( rand == "aceheart.png") || ( rand == "acespade.png") || ( rand ==  "acediam.png"))
              {  group1 = group1 + 1; }
}

function compareOdds()  {

       if (group1 == 0) {
var node=document.createElement("LINE");  // Can you fix my code. I don't want a line.
var textnode=document.createTextNode("-  A = 10:1  -");
node.appendChild(textnode);
document.getElementById("aceOdds").appendChild(node);
} 
  else if (group1 == 1) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  A = 14:1  -");
node.appendChild(textnode);
document.getElementById("aceOdds").appendChild(node);
}
  else if (group1 == 2) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  A = 21:1  -");
node.appendChild(textnode);
document.getElementById("aceOdds").appendChild(node);
}
  else if (group1 == 3) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  A = 43:1  -");
node.appendChild(textnode);
document.getElementById("aceOdds").appendChild(node);
}
  else if (group1 == 4) { 
var node=document.createElement("LINE");
var textnode=document.createTextNode("-  A = 0:0  -");
node.appendChild(textnode);
document.getElementById("aceOdds").appendChild(node);
}

}

//            --------------- Finish Getting Odds Here ----------------

figureOdds()

compareOdds()


This post has been edited by EdNolan: 04 November 2013 - 08:53 PM

Was This Post Helpful? 0
  • +
  • -

#22 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,028
  • Joined: 08-June 10

Re: Adding up values from random arrray

Posted 04 November 2013 - 11:19 PM

first, the code as shown can’t be working—it’s not in a script section.

second, if you want to overwrite results via DOM, you either need to empty container before appending (removeChild()) or you use replaceChild().
Was This Post Helpful? 0
  • +
  • -

#23 EdNolan  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 241
  • Joined: 22-September 13

Re: Adding up values from random arrray

Posted 06 November 2013 - 08:55 PM

Okay I figured out what why the odds section wasn't working with the original <div> I was missing a . so when I solved that I decided to go back and use div and innerHTML. However I now have a new problem. My code picks the first nine cards and displays the odds for the first nine. When it goes to function picAgain(),it picks the remaining, but var rand is still equal to the 9th card picked, and updates the group** for the ninth card over, and over, until it can't update it anymore, and the odds for that 9th card shows 0:0. Any Ideas? Here's the entire code.
<html>
    <head>
        <title>My Game</title>
        <style>
            #tblGuess img {
                width: 36px; height: 48px;
            }
        </style>
    </head>
    <body background="///C:/Users/Dads/Desktop/game/gametemplate2.png">

<table>
      <tr>
      <td>..<img src="1.png" alt="One">..............<div style="float: left; color:#FFFFFF" id="odds1"></div></td><td>..<img src="2.png" alt="Two">..............<div style="float: left; color:#FFFFFF" id="odds2"></div></td><td>..<img src="3.png" alt="Three">.............<div style="float: left; color:#FFFFFF" id="odds3"></div></td><td>..<img src="4.png" alt="Four">.............<div style="float: left; color:#FFFFFF" id="odds4"></div></td><td>..<img src="5.png" alt="Five">.............<div style="float: left; color:#FFFFFF" id="odds5"></div></td><td>..<img src="6.png" alt="Six">.............<div style="float: left; color:#FFFFFF" id="odds6"></div></td><td>..<img src="7.png" alt="Seven">.............<div style="float: left; color:#FFFFFF" id="odds7"></div></td><td>..<img src="8.png" alt="Eight">.............<div style="float: left; color:#FFFFFF" id="odds8"></div></td><td>..<img src="9.png" alt="Nine">.............<div style="float: left; color:#FFFFFF" id="odds9"></div></td><td>..<img src="10.png" alt="Ten">..............<div style="float: left; color:#FFFFFF" id="odds10"></div></td><td>..<img src="J.png" alt="Jack">..............<div style="float: left; color:#FFFFFF" id="oddsJ"></div></td><td>..<img src="Q.png" alt="Queen">.............<div style="float: left; color:#FFFFFF" id="oddsQ"></div></td><td>..<img src="K.png" alt="King"><div style="float: left; color:#FFFFFF" id="oddsK"></div></td>
      </tr>
</table>
        
<script type="text/javascript">

var group1 = 0,group2 = 0,group3 = 0,group4 = 0,group5 = 0,group6 = 0,group7 = 0,group8 = 0,group9 = 0,group10 = 0,group11 = 0,group12 = 0,group13 = 0;

var imgArray = ["aceclub.png", "aceheart.png", "acespade.png", "acediam.png", "twoclub.png", "twoheart.png", "twospade.png", "twodiam.png",
             "threeclub.png", "threeheart.png", "threespade.png", "threediam.png", "fourclub.png", "fourheart.png", "fourspade.png", "fourdiam.png", 
             "fiveclub.png", "fiveheart.png", "fivespade.png", "fivediam.png", "sixclub.png", "sixheart.png", "sixspade.png", "sixdiam.png", 
             "sevenclub.png", "sevenheart.png", "sevenspade.png", "sevendiam.png", "eightclub.png", "eightheart.png", "eightspade.png", "eightdiam.png", 
             "nineclub.png", "nineheart.png", "ninespade.png", "ninediam.png", "tenclub.png", "tenheart.png", "tenspade.png", "tendiam.png",
             "jackclub.png", "jackheart.png", "jackspade.png", "jackdiam.png", "queenclub.png", "queenheart.png", "queenspade.png", "queendiam.png",
             "kingclub.png", "kingheart.png", "kingspade.png", "kingdiam.png"];
           //make a clone of imgArray

var basePath = "///C:/Users/Dads/Desktop/game/";  // This is the file location of all the card images.

function imgRandom() {          // This is the main program.
var clone = imgArray.slice(0);  // We are copying imgArray and will use clone as our working array.
for (i = 0; i < 9; i++) {       // We need our first nine images of the game, this is the start of our loop.
        var i, rand, image;     // These are just some of the variables used in the program
        var shownImages = [];   // I made an empty array that will store each image picked, serves as a record.
var randIndex = Math.floor(Math.random() * clone.length);  // We randomly pick from clone array here.
var rand = clone[randIndex];    // Our image is now known as rand and it's location in the clone array is known as randIndex
        image = new Image();    // or new Image(144, 192); // Here wa are telling the computer we are going to show a new image.
        image.src = basePath + rand;  // Now we have to tell the program to take the random image now called rand from the folder.
        shownImages.push(rand);  // Now I am writing(push) a record of the image(rand). Im putting(push) it in the shownImages array
//        console.log(shownImages[0])
        image.width = 36;        // This sets the images display size that players see on their screens.
        image.height = 48;       // This sets the images display size that players see on their screens.
        document.body.appendChild(image);  // This actually puts the images onto the page as a new image.
clone.splice(randIndex,1);      // This will cut out the image/index from the clone array to avoid duplicates.

figureOdds()

compareOdds()

}

picAgain()
// I NEED TO DISPLAY THE ODDS FOR EACH TURN OF PLAY FOR THIS SECTION TOO !!!
function picAgain(limit) {
    var count = 0;
    function liveCount() {
        count += 1
        if (count <= 28) {    // There are a total of 28 turns of play
var randIndex = Math.floor(Math.random() * clone.length);
var rand = clone[randIndex];
// was here but rand is still equal to pick number 9 and changes the odds of that 9th card until the odds are 0:0
        image = new Image();    // or new Image(144, 192);
        image.src = basePath + rand;
        shownImages.push(rand);
// was here but rand is still equal to pick number 9 and changes the odds of that 9th card until the odds are 0:0
        image.width = 36;
        image.height = 48;
        document.body.appendChild(image);
clone.splice(randIndex,1);

figureOdds()    //  rand thinks is still equal to pick number 9 and changes the odds of that 9th card until the odds are 0:0
compareOdds()

        } else{
            clearInterval();
        }
    }

    var counter = setInterval(liveCount, 3000);
}
// ---------  Start Getting Odds Here --------------------------------------

function figureOdds() {

               if (( rand == "aceclub.png") || ( rand == "aceheart.png") || ( rand == "acespade.png") || ( rand == "acediam.png"))
              {  group1 = group1 + 1; }

               else if (( rand == "twoclub.png") || ( rand == "twoheart.png") || ( rand == "twospade.png") || ( rand == "twodiam.png"))
              {  group2 = group2 + 1; }

               else if (( rand == "threeclub.png") || ( rand == "threeheart.png") || ( rand == "threespade.png") || ( rand == "threediam.png"))
              {  group3 = group3 + 1; }

               else if (( rand == "fourclub.png") || ( rand == "fourheart.png") || ( rand == "fourspade.png") || ( rand == "fourdiam.png"))
              {  group4 = group4 + 1; }

               else if (( rand == "fiveclub.png") || ( rand == "fiveheart.png") || ( rand == "fivespade.png") || ( rand == "fivediam.png"))
              {  group5 = group5 + 1; }

               else if (( rand == "sixclub.png") || ( rand == "sixheart.png") || ( rand == "sixspade.png") || ( rand == "sixdiam.png"))
              {  group6 = group6 + 1; }

               else if (( rand == "sevenclub.png") || ( rand == "sevenheart.png") || ( rand == "sevenspade.png") || ( rand == "sevendiam.png"))
              {  group7 = group7 + 1; }

               else if (( rand == "eightclub.png") || ( rand == "eightheart.png") || ( rand == "eightspade.png") || ( rand == "eightdiam.png"))
              {  group8 = group8 + 1; }

               else if (( rand == "nineclub.png") || ( rand == "nineheart.png") || ( rand == "ninespade.png") || ( rand == "ninediam.png"))
              {  group9 = group9 + 1; }

               else if (( rand == "tenclub.png") || ( rand == "tenheart.png") || ( rand == "tenspade.png") || ( rand == "tendiam.png"))
              {  group10 = group10 + 1; }

               else if (( rand == "jackclub.png") || ( rand == "jackheart.png") || ( rand == "jackspade.png") || ( rand == "jackdiam.png"))
              {  group11 = group11 + 1; }

               else if (( rand == "queenclub.png") || ( rand == "queenheart.png") || ( rand == "queenspade.png") || ( rand == "queendiam.png"))
              {  group12 = group12 + 1; }

               else if (( rand == "kingclub.png") || ( rand == "kingheart.png") || ( rand == "kingspade.png") || ( rand == "kingdiam.png"))
              {   group13 = group13 + 1; }

}

function compareOdds() {
// ----- Ace
             if (group1 == 0) {                //10:1
                document.getElementById("odds1").innerHTML = "10:1";
                                  }

             if (group1 == 1) {                //14:1
                document.getElementById("odds1").innerHTML = "14:1";
                                  }

             if (group1 == 2) {                //21:1
                document.getElementById("odds1").innerHTML = "21:1";
                                  }

             if (group1 == 3) {                //43:1
                document.getElementById("odds1").innerHTML = "43:1";
                                  }

             if (group1 == 4) {                //0:0
                document.getElementById("odds1").innerHTML = "0:0";
                                  }
// ----- Two
             if (group2 == 0) {                //10:1
                document.getElementById("odds2").innerHTML = "10:1";
                                  }

             if (group2 == 1) {                //14:1
                document.getElementById("odds2").innerHTML = "14:1";
                                  }

             if (group2 == 2) {                //21:1
                document.getElementById("odds2").innerHTML = "21:1";
                                  }

             if (group2 == 3) {                //43:1
                document.getElementById("odds2").innerHTML = "43:1";
                                  }

             if (group2 == 4) {                //0:0
                document.getElementById("odds2").innerHTML = "0:0";
                                  }
// ----- Three
             if (group3 == 0) {                //10:1
                document.getElementById("odds3").innerHTML = "10:1";
                                  }

             if (group3 == 1) {                //14:1
                document.getElementById("odds3").innerHTML = "14:1";
                                  }

             if (group3 == 2) {                //21:1
                document.getElementById("odds3").innerHTML = "21:1";
                                  }

             if (group3 == 3) {                //43:1
                document.getElementById("odds3").innerHTML = "43:1";
                                  }

             if (group3 == 4) {                //0:0
                document.getElementById("odds3").innerHTML = "0:0";
                                  }
// ----- Four
             if (group4 == 0) {                //10:1
                document.getElementById("odds4").innerHTML = "10:1";
                                  }

             if (group4 == 1) {                //14:1
                document.getElementById("odds4").innerHTML = "14:1";
                                  }

             if (group4 == 2) {                //21:1
                document.getElementById("odds4").innerHTML = "21:1";
                                  }

             if (group4 == 3) {                //43:1
                document.getElementById("odds4").innerHTML = "43:1";
                                  }

             if (group4 == 4) {                //0:0
                document.getElementById("odds4").innerHTML = "0:0";
                                  }
// ----- Five
             if (group5 == 0) {                //10:1
                document.getElementById("odds5").innerHTML = "10:1";
                                  }

             if (group5 == 1) {                //14:1
                document.getElementById("odds5").innerHTML = "14:1";
                                  }

             if (group5 == 2) {                //21:1
                document.getElementById("odds5").innerHTML = "21:1";
                                  }

             if (group5 == 3) {                //43:1
                document.getElementById("odds5").innerHTML = "43:1";
                                  }

             if (group5 == 4) {                //0:0
                document.getElementById("odds5").innerHTML = "0:0";
                                  }
// ----- Six
             if (group6 == 0) {                //10:1
                document.getElementById("odds6").innerHTML = "10:1";
                                  }

             if (group6 == 1) {                //14:1
                document.getElementById("odds6").innerHTML = "14:1";
                                  }

             if (group6 == 2) {                //21:1
                document.getElementById("odds6").innerHTML = "21:1";
                                  }

             if (group6 == 3) {                //43:1
                document.getElementById("odds6").innerHTML = "43:1";
                                  }

             if (group6 == 4) {                //0:0
                document.getElementById("odds6").innerHTML = "0:0";
                                  }
// ----- Seven
             if (group7 == 0) {                //10:1
                document.getElementById("odds7").innerHTML = "10:1";
                                  }

             if (group7 == 1) {                //14:1
                document.getElementById("odds7").innerHTML = "14:1";
                                  }

             if (group7 == 2) {                //21:1
                document.getElementById("odds7").innerHTML = "21:1";
                                  }

             if (group7 == 3) {                //43:1
                document.getElementById("odds7").innerHTML = "43:1";
                                  }

             if (group7 == 4) {                //0:0
                document.getElementById("odds7").innerHTML = "0:0";
                                  }
// ----- Eight
             if (group8 == 0) {                //10:1
                document.getElementById("odds8").innerHTML = "10:1";
                                  }

             if (group8 == 1) {                //14:1
                document.getElementById("odds8").innerHTML = "14:1";
                                  }

             if (group8 == 2) {                //21:1
                document.getElementById("odds8").innerHTML = "21:1";
                                  }

             if (group8 == 3) {                //43:1
                document.getElementById("odds8").innerHTML = "43:1";
                                  }

             if (group8 == 4) {                //0:0
                document.getElementById("odds8").innerHTML = "0:0";
                                  }
// ----- Nine
             if (group9 == 0) {                //10:1
                document.getElementById("odds9").innerHTML = "10:1";
                                  }

             if (group9 == 1) {                //14:1
                document.getElementById("odds9").innerHTML = "14:1";
                                  }

             if (group9 == 2) {                //21:1
                document.getElementById("odds9").innerHTML = "21:1";
                                  }

             if (group9 == 3) {                //43:1
                document.getElementById("odds9").innerHTML = "43:1";
                                  }

             if (group9 == 4) {                //0:0
                document.getElementById("odds9").innerHTML = "0:0";
                                  }
// ----- Ten
             if (group10 == 0) {                //10:1
                document.getElementById("odds10").innerHTML = "10:1";
                                  }

             if (group10 == 1) {                //14:1
                document.getElementById("odds10").innerHTML = "14:1";
                                  }

             if (group10 == 2) {                //21:1
                document.getElementById("odds10").innerHTML = "21:1";
                                  }

             if (group10 == 3) {                //43:1
                document.getElementById("odds10").innerHTML = "43:1";
                                  }

             if (group10 == 4) {                //0:0
                document.getElementById("odds10").innerHTML = "0:0";
                                  }
// ----- Jack
             if (group11 == 0) {                //10:1
                document.getElementById("oddsJ").innerHTML = "10:1";
                                  }

             if (group11 == 1) {                //14:1
                document.getElementById("oddsJ").innerHTML = "14:1";
                                  }

             if (group11 == 2) {                //21:1
                document.getElementById("oddsJ").innerHTML = "21:1";
                                  }

             if (group11 == 3) {                //43:1
                document.getElementById("oddsJ").innerHTML = "43:1";
                                  }

             if (group11 == 4) {                //0:0
                document.getElementById("oddsJ").innerHTML = "0:0";
                                  }
// ----- Queen
             if (group12 == 0) {                //10:1
                document.getElementById("oddsQ").innerHTML = "10:1";
                                  }

             if (group12 == 1) {                //14:1
                document.getElementById("oddsQ").innerHTML = "14:1";
                                  }

             if (group12 == 2) {                //21:1
                document.getElementById("oddsQ").innerHTML = "21:1";
                                  }

             if (group12 == 3) {                //43:1
                document.getElementById("oddsQ").innerHTML = "43:1";
                                  }

             if (group12 == 4) {                //0:0
                document.getElementById("oddsQ").innerHTML = "0:0";
                                  }
// ----- King
             if (group13 == 0) {                //10:1
                document.getElementById("oddsK").innerHTML = "10:1";
                                  }

             if (group13 == 1) {                //14:1
                document.getElementById("oddsK").innerHTML = "14:1";
                                  }

             if (group13 == 2) {                //21:1
                document.getElementById("oddsK").innerHTML = "21:1";
                                  }

             if (group13 == 3) {                //43:1
                document.getElementById("oddsK").innerHTML = "43:1";
                                  }

             if (group13 == 4) {                //0:0
                document.getElementById("oddsK").innerHTML = "0:0";
                                  }
}

//            --------------- Finished Getting Odds Here ----------------
}  // This ends imgRandom

imgRandom()
        </script>
    </body>
</html>



Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2