theatre22
11-28-2002, 02:12 PM
Hello :)
I am working on a script for a class and having major problems. It is a very simple choose a random site script:
<SCRIPT LANGUAGE="JavaScript">
function randInt(low,high) {
return Math.floor(Math.random()*(high-low+1)+low);
}
function chooseAURL() {
n = randInt(1,2);
if (n == 1) return "http://www.yahoo.com";
else if (n == 2) return "http://www.google.ca";
}
</SCRIPT>
But I'm trying to get the script to run from clicking a button. For most other random site scripts, you do this by doing:
<form>
<p><input type="button" name="B1" value="Random Link" onclick="chooseAURL()"></p> </form>
But this script won't work with that. Does anyone know how I can get this script to work from clicking a button?
Or another script that does something similar, but allows you to have two different sets of random links on the same page?
Any help would be SO appreciated!
I am working on a script for a class and having major problems. It is a very simple choose a random site script:
<SCRIPT LANGUAGE="JavaScript">
function randInt(low,high) {
return Math.floor(Math.random()*(high-low+1)+low);
}
function chooseAURL() {
n = randInt(1,2);
if (n == 1) return "http://www.yahoo.com";
else if (n == 2) return "http://www.google.ca";
}
</SCRIPT>
But I'm trying to get the script to run from clicking a button. For most other random site scripts, you do this by doing:
<form>
<p><input type="button" name="B1" value="Random Link" onclick="chooseAURL()"></p> </form>
But this script won't work with that. Does anyone know how I can get this script to work from clicking a button?
Or another script that does something similar, but allows you to have two different sets of random links on the same page?
Any help would be SO appreciated!