Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
11-09-2011, 06:34 PM #1
- Join Date
- Nov 2011
- Thanked 0 Times in 0 Posts
I'm doing an assignment for class and I'm unable to figure this all out.
Here is the assignment:
Give the first div in the body an id of "diceHere". Create a function that populates "diceHere" after rolling, instead of hard-coding it into the body.
Add a text box that allows the user to request between 1 and 6 dice, then add a parameter to the function which passes that number through.
Make sure that your dice function also has a parameter for passing the paragraph id.
Create a variable that allows you to store a string that will write the proper number of die images to your page.
Here is what I have so far:
<title> Die Rolls </title>
roll = Math.floor(Math.random()*(6) + 1);
imgName = 'die' + roll + '.gif';
document.getElementById('dieImg').src = imgName;
<div style="text-align:center" id=diceHere>
<img id="dieImg" alt="die image"
<input type="button" value="Click to Roll" onClick="diceRoll();">
Can anyone help me with this?