ok, here is the latest. Ive done forest and aquatic for you. You will need to do the rest. Tested in a browser, but not Realm Works:
Code:
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Crown of the World Random Encounters</TITLE>
</HEAD>
<BODY>
<script language="JavaScript">
// Some Arrays
var forestArray = [];
var aquaticArray = [];
forestArray.push( {"max": 18, "content": "1 draugr; CR 2; Bestiary 2 110" });
forestArray.push({"max": 31, "content": "1 bunyip; CR 3; Bestiary 2 50"});
forestArray.push({"max": 59, "content": "1 orca; CR 5; Bestiary 88"});
forestArray.push({"max": 72, "content": "1 selkie; CR 5; Pathfinder #50 pg 88"});
forestArray.push({"max": 84, "content": "1 glacier toad; CR 6; Bestiary 2 268"});
forestArray.push({"max": 100,"content": "1 qallupilluk; CR 7; Pathfinder #51 pg 88"});
aquaticArray.push({"max": 70, "content": "another shark"});
aquaticArray.push({"max": 100, "content": "a nice dolphin"});
var allArrays = {
"forest": forestArray,
"aquatic": aquaticArray
};
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}
function rand(number) {
return Math.ceil(rnd()*number);
}
function tableResults(argument) {
var randomNum = rand(100) + 1;
console.log(randomNum);
var arrayOfChoices = allArrays[argument];
if (!arrayOfChoices) {
return "no such set: " + argument;
}
var chosenString = "";
for (var itemIndex in arrayOfChoices) {
var item = arrayOfChoices[itemIndex];
if (randomNum <= item.max) {
chosenString = item.content;
break;
}
}
return chosenString;
}
</script>
<form>
<input type="button" name="Button1" value="Aquatic" onClick="this.form.textField1.value = tableResults('aquatic')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>
<form>
<input type="button" name="Button2" value="Forest" onClick="this.form.textField1.value = tableResults('forest')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>
<form>
<input type="button" name="Button3" value="Hills" onClick="this.form.textField1.value = tableResults()" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>
<form>
<input type="button" name="Button4" value="Mountains" onClick="this.form.textField1.value = tableResults()" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>
<form>
<input type="button" name="Button5" value="Tundra" onClick="this.form.textField1.value = tableResults()" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>
</BODY>
</HTML>