Jump to content

Generate Random Numbers. Ajax/php


agnarkb

Recommended Posts

I´m currently working on a Bingo project. I have written a script, using JS and HTML for the webpage, that generates a bingo card with random numbers. However, I´m now having problems with what I thought would be relatively simple. The bingo number caller or whatever it is called. The idea I had was to use AJAX and it would display random chars and numbers[b1, O67...] that would be the bingo caller in a horizontal line below the card.I have tried everything I know but I just can´t get it to work. Do you have any codes that do this sort of things or similar?

Link to comment
Share on other sites

Can you show your code? How is it not working?
Used some of a code to create the bingo card from a book I own.Then I tried writing some code to do the random numbers. I couldn´t do it right with AJAX. The only code that somewhat worked, but not totally what I was looking for.div:
<div id='random'></div><br />	<input name="button" type="button" value="Click" onClick="randomBingoCallNumber(75,25)"/> </div>

java script:

var i=1;function randomBingoCallNumber(maximumValue, numberOfTimes){ i++;  document.getElementById('random').innerHTML='';  var Number = Math.Floor((Math.random()*parseInt(maxVal)).toFixed(2));  document.getElementById('random').innerHTML=Number; //gett if(i< = numberOfTimes)   setTimeout("randomBingoCallNumber("+maximumValue+","+numberOfTimes+")",500); else 	i=1;}

I want it to use AJAX to make it refresh automatically, not pushing a button.

Link to comment
Share on other sites

var Number = Math.Floor((Math.random()*parseInt(maxVal)).toFixed(2));That variable is undefined.if(i< = numberOfTimes)It's not valid to have a space there, the operator is "<=". With a space it's 2 different operators.

Link to comment
Share on other sites

Are you using AJAX because you have multiple players on multiple browsers? That's going to open up a lot of other issues, too.If you simply want an automated process, look into the Javascript setInterval() functionThat can be used locally, or to call a PHP script at regular intervals via AJAX.

Link to comment
Share on other sites

Are you using AJAX because you have multiple players on multiple browsers? That's going to open up a lot of other issues, too.If you simply want an automated process, look into the Javascript setInterval() functionThat can be used locally, or to call a PHP script at regular intervals via AJAX.
I mostly want an automated process. Like it would be in real life.
Link to comment
Share on other sites

With this line in there:document.getElementById('random').innerHTML='';It's going to delete the contents of that div every time it runs the function. So the first time it runs, it will delete the contents, then print a number there. The second time it runs, when i=2, it will again delete the contents and print another number there. So after 25 times you'll end up with 1 number there.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...