falisco
06-30-2016, 11:53 AM
I want to have random (texts, unique codes) that appear upon refreshing the page.
The idea is I want to send people to a page where they can get access to a code like this for example: 9KKR-GMMGWX-WXEJYL
and when they refresh the page, or a new person visits the page a new code would appear like this for example: 55E9-V4SHSR-7A6JCL
However, what I want to do is have it so that it does NOT repeat a code if they have previously been selected.
I found this javascript in this website which is close to what I'm trying to accomplish:
<html>
<head>
<script type="text/javascript">
var pic = [];
pic[0] = "Adam Arnold";
pic[1] = "Brenda Beeston";
pic[2] = "Carl Carlton";
pic[3] = "Deborah Daybrook";
pic[4] = "Eric Eastwood";
pic[5] = "Francis Findern";
pic[6] = "Greg Grantham";
pic[7] = "Hilda Heanor";
pic[8] = "Ian Ilkeston";
pic[9] = "Jenny Japan";
pic[10] = "Keith Kimberley";
pic[11] = "Lucy London";
function pupilsname() {
randomNum = Math.floor(Math.random()*pic.length);
return pic.splice(randomNum, 1)[0] || "Sorry, no more names left.";
}
function tools() {
var pic = new Array();
pic[0] = "Pick a name from the hat";
randomNum = Math.floor(Math.random()*pic.length);
return pic[randomNum];
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><center>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top" bgcolor="#FFFFFFF"><table width="80%" height="220" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="60" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><font size="6" color="#000000"><strong>Big Wood School Random Name Generator</strong></font></td>
</tr>
</table></td>
</tr>
<tr>
<td width="50%" rowspan="2" align="center" valign="middle" bgcolor="#FFFFFF"><p> <a href="#"
onMouseOver="document.getElementById('myText1').innerHTML = pupilsname() ;" onMouseOut="document.getElementById('myText1').innerHTML = tools() ;""><font size="3"><font size=5><strong>Pick a pupil</strong></font></a>
</li>
</p></td>
<td width="50%" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#FFFFFF"><font size="6" color="#000000">
<div id="myText1" onMouseOver="this.innerHTML = tools();">Pick a name from the hat</div>
</font></td>
</tr>
</table></td>
</tr>
</table></center>
</body>
</html>
However instead of names being changed on mouse over, I want unique codes to change upon refreshing the page, no table needed nor headline needed
I just want the codes to show up randomly without repeat, and if all the codes showed up, a message would appear saying " sorry no more codes left"
I know this is possible,
your help is much appreciated
thanks
Many thanks,
The idea is I want to send people to a page where they can get access to a code like this for example: 9KKR-GMMGWX-WXEJYL
and when they refresh the page, or a new person visits the page a new code would appear like this for example: 55E9-V4SHSR-7A6JCL
However, what I want to do is have it so that it does NOT repeat a code if they have previously been selected.
I found this javascript in this website which is close to what I'm trying to accomplish:
<html>
<head>
<script type="text/javascript">
var pic = [];
pic[0] = "Adam Arnold";
pic[1] = "Brenda Beeston";
pic[2] = "Carl Carlton";
pic[3] = "Deborah Daybrook";
pic[4] = "Eric Eastwood";
pic[5] = "Francis Findern";
pic[6] = "Greg Grantham";
pic[7] = "Hilda Heanor";
pic[8] = "Ian Ilkeston";
pic[9] = "Jenny Japan";
pic[10] = "Keith Kimberley";
pic[11] = "Lucy London";
function pupilsname() {
randomNum = Math.floor(Math.random()*pic.length);
return pic.splice(randomNum, 1)[0] || "Sorry, no more names left.";
}
function tools() {
var pic = new Array();
pic[0] = "Pick a name from the hat";
randomNum = Math.floor(Math.random()*pic.length);
return pic[randomNum];
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><center>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top" bgcolor="#FFFFFFF"><table width="80%" height="220" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="60" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><font size="6" color="#000000"><strong>Big Wood School Random Name Generator</strong></font></td>
</tr>
</table></td>
</tr>
<tr>
<td width="50%" rowspan="2" align="center" valign="middle" bgcolor="#FFFFFF"><p> <a href="#"
onMouseOver="document.getElementById('myText1').innerHTML = pupilsname() ;" onMouseOut="document.getElementById('myText1').innerHTML = tools() ;""><font size="3"><font size=5><strong>Pick a pupil</strong></font></a>
</li>
</p></td>
<td width="50%" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#FFFFFF"><font size="6" color="#000000">
<div id="myText1" onMouseOver="this.innerHTML = tools();">Pick a name from the hat</div>
</font></td>
</tr>
</table></td>
</tr>
</table></center>
</body>
</html>
However instead of names being changed on mouse over, I want unique codes to change upon refreshing the page, no table needed nor headline needed
I just want the codes to show up randomly without repeat, and if all the codes showed up, a message would appear saying " sorry no more codes left"
I know this is possible,
your help is much appreciated
thanks
Many thanks,