In Dungeons and Dragons, dice rolls are set up like this #d#+#. X is the number of times you roll the die (or the number of dice rolled, either way, the same thing), Y is how many sides the die(dice) have, and Z is the optional enhancement. You first add up the total of the rolls of Y, then add Z to that... It may be easier to visualize what I'm trying to do if you run this in your browser. I put an <!-- HTML comment --> on the line I'm getting the error at.
... All this because I'm too cheap/lazy to buy real dice. Heh.
<html>
<head>
<title>DnD Die Roller</title>
<script>
function roll()
{
var textfield1 = window.document.form1.textfield1.value;
var textfield2 = window.document.form1.textfield2.value;
var textfield3 = window.document.form1.textfield3.value;
var result = 0;
while(textfield1 > 0)
{
var roll = Math.round(Math.random())
textfield1 - 1;
var result1 = roll * textfield2;
result = result + result1;
}
result = result + textfield3;
window.document.form1.textfield4.value = result;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><b><font face="Arial">Dungeons and Dragons Die Roller</font></b></p>
<!-- ALWAYS GET ERROR ON THIS LINE. BROKE IT DOWN, ERROR COMING FROM |onSubmit="roll();|. JUST THAT BIT, I PUT IT ON ITS OWN LINE AND TESTED. THAT IS WHERE ERROR COMING FROM. PROBABLY AN ERROR IN THE BODY OF THE SCRIPT ABOVE. --><form name="form1" onSubmit="roll(); returnfalse;">
<input type="text" name="textfield1" maxlength="6">
<b><font face="Arial">d
<input type="text" name="textfield2" maxlength="6">
+
<input type="text" name="textfield3" maxlength="6">
<input name="roll" type="submit" value="Roll"></font></b>
<b><font face="Arial">Result:</font></b>
<input type="text" name="textfield4" maxlength="6">
</form>
<p></p>
</body>
</html>
... All this because I'm too cheap/lazy to buy real dice. Heh.
<html>
<head>
<title>DnD Die Roller</title>
<script>
function roll()
{
var textfield1 = window.document.form1.textfield1.value;
var textfield2 = window.document.form1.textfield2.value;
var textfield3 = window.document.form1.textfield3.value;
var result = 0;
while(textfield1 > 0)
{
var roll = Math.round(Math.random())
textfield1 - 1;
var result1 = roll * textfield2;
result = result + result1;
}
result = result + textfield3;
window.document.form1.textfield4.value = result;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><b><font face="Arial">Dungeons and Dragons Die Roller</font></b></p>
<!-- ALWAYS GET ERROR ON THIS LINE. BROKE IT DOWN, ERROR COMING FROM |onSubmit="roll();|. JUST THAT BIT, I PUT IT ON ITS OWN LINE AND TESTED. THAT IS WHERE ERROR COMING FROM. PROBABLY AN ERROR IN THE BODY OF THE SCRIPT ABOVE. --><form name="form1" onSubmit="roll(); returnfalse;">
<input type="text" name="textfield1" maxlength="6">
<b><font face="Arial">d
<input type="text" name="textfield2" maxlength="6">
+
<input type="text" name="textfield3" maxlength="6">
<input name="roll" type="submit" value="Roll"></font></b>
<b><font face="Arial">Result:</font></b>
<input type="text" name="textfield4" maxlength="6">
</form>
<p></p>
</body>
</html>
Comment