<html>
<head>
<title> Dice Roller </title>
<script type="text/javascript" src="Dice%20Roller_files/random.js">
</script>
<script type="text/javascript">
function RollUntilDoubles()
{
var roll1, roll2;
roll1 = RandomInt(1, 6);
roll2 = RandomInt(1, 6);
document.getElementById('outputDiv').innerHTML=roll1+'-'+roll2+'<br >';
while (roll1 != roll2) {
roll1 = RandomInt(1, 6);
roll2 = RandomInt(1, 6);
document.getElementById('outputDiv').innerHTML =
document.getElementById('outputDiv').innerHTML+roll1+'-'+roll2+'<br>';
}
document.getElementById('outputDiv').innerHTML =
document.getElementById('outputDiv').innerHTML+'DOUBLES!';
}
</script>
</head>
<body>
<h2>Dice Roller</h2>
<input type="button" value="Roll until doubles" onclick="RollUntilDoubles();">
<hr>
<div id="outputDiv">2-1<br>4-3<br>5-4<br>5-6<br>1-4<br>5-4<br>5-4<br>2-2<br>DOUBLES!</div>
</body>
</html>
I think you may be confusing Java with JavaScript, and I suspect that there’s a bunch of code that your post isn’t showing?
use one of the two following options to make your code/indent is visible:
select your code and press ctrl + shift + c (or cmd + shift + c if you use a mac)
if this instructions are unclear, you can also insert 3 backticks before and after your code, like so:
```
<p>visible</p>
```
the backtick is located above the tab key on your keyboard. If you edit/update your question, leave a reply so we get a notification
<!DOCTYPE html>
<!-- roll.html joshweaver -->
<!-- This page simulates dice rolls until doubles are obtained. -->
<!-- ========================================================== -->
<html>
<head>
<title> Dice Roller </title>
<script type="text/javascript" src="Dice%20Roller_files/random.js">
</script>
<script type="text/javascript">
function RollUntilDoubles()
roll1 = -1; //primed by assigning values to variables
roll2 = -2;
document.getElementById('outputDiv').innerHTML= '';
while (roll1 != roll2){
roll1 = RandomInt(1, 6);
roll2 = RandomInt(1, 6);
document.getElementById('outputDiv').innerHTML =
document.getElementById('outputDiv').innerHTML +roll1+'-'+roll2+'<br';
}
</script>
</head>
<body>
<h2>Dice Roller</h2>
<input type="button" value="Roll until doubles" onclick="RollUntilDoubles();">
<hr>
<div id="outputDiv">2-1<br>4-3<br>5-4<br>5-6<br>1-4<br>5-4<br>5-4<br>2-2<br>DOUBLES!</div>
</body>
</html>
Thats were i think im trying to go with it … The first post is the initial page created and i was only left a brief description as to how to "prime the loop ". 2nd HTML is my attempt
obviously doing it wrong
Well, can we have access to this file: src=“Dice%20Roller_files/random.js”? Because that might change everything.
This isn’t Java nor is it part of any courses, this thread should be in Corner Bar.