Why doesn't this work? (Javascript&PHP)

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
kyle04
New php-forum User
New php-forum User
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Wed Oct 03, 2012 3:03 pm

The javascript part is looping only, not the php generated number.
You can do this with javascript only :

Code: Select all

<script language="javascript" type="text/javascript">
function randomString() {
	var chars = "0123456789";  // numbers only
	var string_length = 8;  // number string length
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}

var e = document.getElementById("test");
    e.innerHTML = e.innerHTML + randomstring + "<br>";

}

setInterval(randomString, 1000); 

</script>
<div id="test"></div> 

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests