the oso
10-13-2008, 10:57 PM
I'm just trying to get this code to randomly select a restaurant to eat at when the button is clicked. I'm having trouble doing the random part. here is the code I got:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Random Restaraunt Selector</title>
<script type="text/javascript">
//PTE = Place to eat
<!--
function getpte(ptenum) {
return Math.floor(Math.random()* ptenum);
}
//-->
</script>
</head>
<body>
<h2>Random Restaraunt Selector</h2>
<script type="text/javascript">
<!--
var pte = new Array("Jimmy John's","Momo's","Subway", "Pita Pit", "Fresh Stirfry", "Cici's", "Quiznos", "Hungry Howies", "Decent Pizza", "Stevi B's", "Wendy's", "Super Perros");
for (x in pte)
{
document.write(pte[x] + "<br />");
}
//-->
getpte = ptenum(12); // 12 values, 0 - 11
document.write("The Winner is... ");
document.write(ptenum);
</script>
<form>
<p></p>
<p><input type="button" value="Click me!" onclick="getpte(this.form.pte.value)" /></p>
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Random Restaraunt Selector</title>
<script type="text/javascript">
//PTE = Place to eat
<!--
function getpte(ptenum) {
return Math.floor(Math.random()* ptenum);
}
//-->
</script>
</head>
<body>
<h2>Random Restaraunt Selector</h2>
<script type="text/javascript">
<!--
var pte = new Array("Jimmy John's","Momo's","Subway", "Pita Pit", "Fresh Stirfry", "Cici's", "Quiznos", "Hungry Howies", "Decent Pizza", "Stevi B's", "Wendy's", "Super Perros");
for (x in pte)
{
document.write(pte[x] + "<br />");
}
//-->
getpte = ptenum(12); // 12 values, 0 - 11
document.write("The Winner is... ");
document.write(ptenum);
</script>
<form>
<p></p>
<p><input type="button" value="Click me!" onclick="getpte(this.form.pte.value)" /></p>
</form>
</body>
</html>