Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2011, 06:34 PM   PM User | #1
z3r0312
New to the CF scene

 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
z3r0312 is an unknown quantity at this point
Html 5 javascript help

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:

<!DOCTYPE html>
<html>
<head>
<title> Die Rolls </title>
<script type="text/javascript">
function diceRoll()
{
roll = Math.floor(Math.random()*(6) + 1);
imgName = 'die' + roll + '.gif';
document.getElementById('dieImg').src = imgName;
}
</script>

</head>

<body>
<br/><br/>
<div style="text-align:center" id=diceHere>

<img id="dieImg" alt="die image"
src="die1.gif">

</p>
<input type="button" value="Click to Roll" onClick="diceRoll();">
</div>
</body>
</html>


Can anyone help me with this?
z3r0312 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:08 AM.


Advertisement
Log in to turn off these ads.