More cool scripts: Slide Show: What the settimeout() function does:

Similar documents
Loops/Confirm Tutorial:

First, create a web page with a submit button on it (remember from creating forms in html?):

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28

How the Internet Works

JS Lab 1: (Due Thurs, April 27)

JavaScript: Tutorial 5

For loops and Window Objects:

Arrays/Branching Statements Tutorial:

Create a cool image gallery using CSS visibility and positioning property

Project 2: After Image

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

Vebra Search Integration Guide

CSS Tutorial Part 1: Introduction: A. Adding Style to a Web Page (3 options):

Implementing a chat button on TECHNICAL PAPER

Overview. Part I: Portraying the Internet as a collection of online information systems HTML/XHTML & CSS

Unit Notes. ICAWEB411A Produce basic client-side script for dynamic web pages Topic 1 Introduction to JavaScript

What is XHTML? XHTML is the language used to create and organize a web page:

(Refer Slide Time: 01:40)

The default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows:

CoderDojo Activity Cards: The Cards (Animation2.html): How to use: Student comes to mentor, and together they choose a card to do next.

ORB Education Quality Teaching Resources

c122mar413.notebook March 06, 2013

CMT111-01/M1: HTML & Dreamweaver. Creating an HTML Document

JavaScript Introduction

c122jan2714.notebook January 27, 2014

HTML Tags (Tutorial, Part 2):

CSCI 1100L: Topics in Computing Spring 2018 Web Page Project 50 points

Dynamism and Detection

Schenker AB. Interface documentation Map integration

var num1 = prompt("enter a number between 1 and 12","1"); var promptstring = "What is " + num1 + " times 3?"; var num2 = prompt(promptstring);

javascript Tutorial 4

OrbBasic Lesson 1 Goto and Variables: Student Guide

Introduction to HTML5

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

OrbBasic 1: Student Guide

The first sample. What is JavaScript?

Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5

HTML Overview. With an emphasis on XHTML

How browsers talk to servers. What does this do?

Shane Gellerman 10/17/11 LIS488 Assignment 3

introduction to XHTML

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional

GIMP WEB 2.0 MENUS. Before we begin this tutorial let s visually compare a standard navigation bar and a web 2.0 navigation bar.

1. Please, please, please look at the style sheets job aid that I sent to you some time ago in conjunction with this document.

3 Categories and Attributes

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

By the end of this section of the practical, the students should be able to:

Exam Format: Multiple Choice, True/False, Short Answer (3 points each 75 points total) Write-the-page (25 points)

CS134 Web Site Design & Development. Quiz1

ANSWER KEY Exam I (Yellow Version) CIS 228: The Internet Prof. St. John Lehman College City University of New York 26 February 2009

JS Tutorial 3: InnerHTML Note: this part is in last week s tutorial as well, but will be included in this week s lab

Enhancing Web Pages with JavaScript

Web Programming/Scripting: JavaScript

In this project, you ll learn how to create your own webpage to tell a story, joke or poem. Think about the story you want to tell.

If you re serious about Cookie Stuffing, take a look at Cookie Stuffing Script.

Dreamweaver CS3 Lab 2

Lab 4 CSS CISC1600, Spring 2012

Dreamweaver CS5 Lab 4: Sprys

<script> function yourfirstfunc() { alert("hello World!") } </script>

Microsoft Expression Web Quickstart Guide

MP3 (W7,8,&9): HTML Validation (Debugging) Instruction

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

Recall: Document Object Model (DOM)

Creating Breakout - Part 2

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Using htmlarea & a Database to Maintain Content on a Website

Designing Your Teacher Page. Medora Community School Corporation

jquery Tutorial for Beginners: Nothing But the Goods

Chapter 4. Introduction to XHTML: Part 1

Documents and computation. Introduction to JavaScript. JavaScript vs. Java Applet. Myths. JavaScript. Standard

Clickbank Domination Presents. A case study by Devin Zander. A look into how absolutely easy internet marketing is. Money Mindset Page 1

introjs.notebook March 02, 2014

I Can t Believe It s Not

PIC 40A. Midterm 1 Review

What Are CSS and DHTML?

Animations involving numbers

Web Development & Design Foundations with XHTML. Chapter 2 Key Concepts

Writing Perl Programs using Control Structures Worked Examples

Spam. Time: five years from now Place: England

HTML 5 Form Processing

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

A designers guide to creating & editing templates in EzPz

OrbBasic LESSON 1 Goto and Variables Student Guide

Quick.JS Documentation

PBWORKS - Student User Guide

Part 3: Images & form styling NOMZAMO S WEBSITE

Bookmarks to the headings on this page:

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

DIRECTV Message Board

The smarter, faster guide to Microsoft Outlook

Dreamweaver: Portfolio Site

1$ 5 ! $ 6 4 * Source: 0 "!*! 0! * 8 97 ?!$ 5 0 *! 4! $ 0 : * ' () 7;7 7<7

New Media Production HTML5


Problem Set 7: Website Development

Dreamweaver CS5 Lab 2

JavaScript (5A) JavaScript

What do we mean by layouts?

CONVERSION TRACKING PIXEL GUIDE

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Transcription:

More cool scripts: Slide Show: So far the user has controlled the action. However, you can make a slide show that automatically cycles through each image in an array and goes to the next image at an incremental time. You do this by adding a call to a settimeout() function (already written by Javascript) that basically does nothing for a set amount of time, then calls your first function over again. So you ve already written a JavaScript that cycles through each image in an array. The following code should look familiar: <script type = "text/javascript"> imgarray = new Array() imgarray [0] = "kittyfur-back.jpg" imgarray [1] = "kittyhimself.jpg" imgarray [2] = "kittybreakfast.jpg" imgarray [3] = "kittyno-regrets.jpg" imgarray [4] = "kttylemon.jpg" imgarray [5] = "kittypanda.jpg" arraycounter = 0 function ChangePic() document.images[ kittypic1 ].src = imgarray[arraycounter] arraycounter = arraycounter + 1 if (arraycounter == imgarray.length) arraycounter = 0 First, we ll modify this by adding a call to a function settimeout(). What the settimeout() function does: settimeout() is a function that in essence causes the JavaScript code to pause working. No matter what the JavaScript code is doing, when it hits the line that calls settimeout(), it pauses. How long does it pause? As long as we tell it too. One of the parameters we send into the settimeout() function is the number of milliseconds we want it to pause for. So the call looks like this: settimeout( Function1(),5000) the pause will be for 5000 milliseconds. Then after the pause, settimeout() will call the function Function1(). Here is an example of using settimeout to change the color of a button back to black after 5000 msec. Try it: <script type="text/javascript"> function settored ( ) document.getelementbyid("colourbutton").style.color = "#FF0000"; settimeout ( "settoblack()", 2000 ); 1

function settoblack ( ) document.getelementbyid("colourbutton").style.color = "#000000"; <input type="button" name="clickme" id="colourbutton" value="click me and wait!" onclick="settored()"/> For our slide show, I ll make the timeout last for 3000 milliseconds, and when it s over, I want to call the ChangePic() function so that the next picture comes up. To do that, at the end of the ChangePic function, I ll add: settimeout( ChangePic(),3000) So my function now looks like this: function ChangePic() document.images[ kittypic1 ].src = imgarray[arraycounter] arraycounter = arraycounter + 1 if (arraycounter == imgarray.length) arraycounter = 0 settimeout( ChangePic(),3000) Now what happens is whenever the ChangePic() function is called, it sets the image with the id kittypic1 s source to whatever is in the imgarray[arraycounter]. I then add one to arraycounter and check to see if the arraycounter is equal to the length of the imgarray. If it is, I reset the arraycounter back to 0. And now I pause the javascript for 3000 msec. When 3000 msec is up, the function ChangePic() is started over from the beginning. Make sense? The only thing left is to add an image in my web page with the id of kittypic1. I could make the slideshow start when I clicked on the image associated with the id kittypic1 (you know how to do this, right?), but I think in this case I would like the slideshow to start as soon as the web page loads. So I am going to add to the <body> tag an event handler for onload. It will look like this: <body onload = ChangePic() > <img src = kittyjumping.jpg width = 500 height = 250 alt = a pic of a kitty jumping id = kittpic1 /> Now when my web page loads into the browser, the function ChangePic() will be called and the slideshow will start. Your Turn: Make a slide show. Put together the JavaScript at the top, with an array, a counter, and a change image function, then add the settimeout() call. Make sure there s an image in your web page with the correct id, and then add the onload event to the body. 2

Text for slideshow: You may wish to cycle through text as you cycle through your slideshow (think of vacation pictures, each with their own text associated with them). To do this, you will need to create an array of text. The array will need to be the exact same length as the array of images if you want them to synch up. If you don t, it doesn t matter how long the text array is. For now, I ll make them be the same length: textarray = new Array() textarray[0] = picture of grumpy cat and a big pile of fur textarray[1] = baby kitten wanting to hold bottle of milk textarray[2] = cat looking at clock and demanding breakfast textarray[3] = kitty has gone through a whole roll of toilet paper textarray[4] = kitty with a very sour look on his face because he ate a lemon textarray[5] = Panda fell head-first off a slide Then inside the ChangePic() function, you need to add the code that changes the innerhtml of the id associated with the text you want to change. Thus if, in your code you ve got <p id = piclabels >Text associated with pictures </p> You ll add to your ChangePic() function: function ChangePic() document.images["kittypic1"].src = imgarray[arraycounter] document.getelementbyid("piclabels").innerhtml = textarray[arraycounter] arraycounter = arraycounter + 1 if (arraycounter == imgarray.length) arraycounter = 0 settimeout("changepic()",3000) That should do it. Now when you load your page, both the picture and the text below it should cycle through Your turn: Make sure this works for you. Get a page with an image and text rotating through a slide show when the web page loads into the browser. Changing Style So far we ve changed images and text, but we have only done a little with changing the style of a web page. JavaScript lets us do that as well. We can call a function that allows us to change the style of one or many elements on the web page. We can do that as we ve been doing it, but instead, let s use a form s submit button. First, create a web page with a submit button on it (remember from creating forms in html?): <input type = "submit" id = "redbtn" value = "red" onclick = "ChangeStyle('red')" /> Next we create a function that changes the style of a particular element. For now, I am going to just change the background color of the entire body of the web page. So my function will look like this: 3

function ChangeStyle(colorholder) document.body.style.backgroundcolor = "#FF0000" Put it all together, and you get: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html lang="en-us" xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>our first javascript!</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type = "text/javascript"> function ChangeStyle(colorholder) document.body.style.backgroundcolor = "#FF0000" </head> <body> <input type = "submit" id = "redbtn" value = "red" onclick = "ChangeStyle('red')" /> </html> Your turn: Try this. Create a basic web page with a button that, when clicked on, turns the web page background color to red. Different Colors: Let s expand this. Let s create a bunch of buttons that allow us to change the background color to different colors. First, let s create some more buttons: <input type = "submit" id = "redbtn" value = "red" onclick = "ChangeStyle('red')" /> <input type = "submit" id = "yellowbtn" value = "yellow" onclick = "ChangeStyle('yellow')" /> <input type = "submit" id = "greenbtn" value = "green" onclick = "ChangeStyle('green')" /> <input type = "submit" id = "cyanbtn" value = "cyan" onclick = "ChangeStyle('cyan')" /> <input type = "submit" id = "bluebtn" value = "blue" onclick = "ChangeStyle('blue')" /> <input type = "submit" id = "purplebtn" value = "purple" onclick = "ChangeStyle('purple')" /> Then let s modify the ChangeStyle() function so that when it is called with a particular variable, the body s background color changes to the appropriate color: function ChangeStyle(colorholder) if (colorholder == "red") document.body.style.backgroundcolor = "#FF3322" else if (colorholder == "yellow") document.body.style.backgroundcolor = "#FCEF04" 4

else if (colorholder == "green") document.body.style.backgroundcolor = "#22DE43" else if (colorholder == "cyan") document.body.style.backgroundcolor = "#10FAE4" else if (colorholder == "blue") document.body.style.backgroundcolor = "#4201D3" else if (colorholder == "purple") document.body.style.backgroundcolor = "#B900CD" Your turn: Modify your web page so that you ve got a bunch of different buttons at the top, and each one changes the background color to a different color Changing Style of other elements: So far we ve changed the background color of the web page. We can change the style of other elements on the page as well. Of course, we ll need other elements on the page. First, create another element on the page. I m going to add a header: <body> <input type = "submit" id = "redbtn" value = "red" onclick = "ChangeStyle('red')" /> <input type = "submit" id = "yellowbtn" value = "yellow" onclick = "ChangeStyle('yellow')" /> <input type = "submit" id = "greenbtn" value = "green" onclick = "ChangeStyle('green')" /> <input type = "submit" id = "cyanbtn" value = "cyan" onclick = "ChangeStyle('cyan')" /> <input type = "submit" id = "bluebtn" value = "blue" onclick = "ChangeStyle('blue')" /> <input type = "submit" id = "purplebtn" value = "purple" onclick = "ChangeStyle('purple')" /> <h1 id = firstheader > Our Dynamic Style Page </h1> Now, when a button is clicked, I m going to alter the background color of the firstheader element as well as the background color of the entire page: function ChangeStyle(colorholder) if (colorholder == "red") document.body.style.backgroundcolor = "#FF3322" document.getelementbyid('firstheader').style.backgroundcolor = "#57AF33" else if (colorholder == "yellow") document.body.style.backgroundcolor = "#FCEF04" document.getelementbyid('firstheader').style.backgroundcolor = "#7788CC" 5

else if (colorholder == "green") document.body.style.backgroundcolor = "#22DE43" document.getelementbyid('firstheader').style.backgroundcolor = "#0055FF" else if (colorholder == "cyan") document.body.style.backgroundcolor = "#10FAE4" document.getelementbyid('firstheader').style.backgroundcolor = "#E410FA" else if (colorholder == "blue") document.body.style.backgroundcolor = "#4201D3" document.getelementbyid('firstheader').style.backgroundcolor = "#F3F300" else if (colorholder == "purple") document.body.style.backgroundcolor = "#B900CD" document.getelementbyid('firstheader').style.backgroundcolor = "#BBAADD" I m going to modify some other style properties of the firstheader element by adding: document.getelementbyid('firstheader').style.fontsize = "45px" document.getelementbyid('firstheader').style.fontfamily = "arial" document.getelementbyid('firstheader').style.padding = "20px" document.getelementbyid('firstheader').style.fontstyle = "italic" document.getelementbyid('firstheader').style.textalign = "right" document.getelementbyid('firstheader').style.borderstyle = "solid" document.getelementbyid('firstheader').style.borderwidth = "4px" My function will now look like: function ChangeStyle(colorholder) if (colorholder == "red") document.body.style.backgroundcolor = "#FF3322" document.getelementbyid('firstheader').style.backgroundcolor = "#57AF33" else if (colorholder == "yellow") document.body.style.backgroundcolor = "#FCEF04" document.getelementbyid('firstheader').style.backgroundcolor = "#7788CC" else if (colorholder == "green") document.body.style.backgroundcolor = "#22DE43" document.getelementbyid('firstheader').style.backgroundcolor = "#0055FF" else if (colorholder == "cyan") document.body.style.backgroundcolor = "#10FAE4" document.getelementbyid('firstheader').style.backgroundcolor = "#E410FA" 6

else if (colorholder == "blue") document.body.style.backgroundcolor = "#4201D3" document.getelementbyid('firstheader').style.backgroundcolor = "#F3F300" else if (colorholder == "purple") document.body.style.backgroundcolor = "#B900CD" document.getelementbyid('firstheader').style.backgroundcolor = "#BBAADD" document.getelementbyid('firstheader').style.fontsize = "45px" document.getelementbyid('firstheader').style.fontfamily = "arial" document.getelementbyid('firstheader').style.padding = "20px" document.getelementbyid('firstheader').style.fontstyle = "italic" document.getelementbyid('firstheader').style.textalign = "right" document.getelementbyid('firstheader').style.borderstyle = "solid" document.getelementbyid('firstheader').style.borderwidth = "4px" Your Turn: Add this to your web page. Cool, huh. Feel free to play around. Assignment: Think about your average web page. Then think about adding a button that would adapt the page for those with red-green or blue-yellow color blindness. What about those with low vision who need a web page with high contrast? Loop Code for selecting a background image: So far we ve used an if condition to control when we do particular statements. In an if condition, you say something like, if (var1 == cat ) document.write( <p>it s a cat!</p> ) In this case the document.write code is only executed when (var1 == cat ) is true (meaning var1 does, in fact, hold cat ). A variant on this is a loop. With a loop javascript continues to do the statements as long as the condition remains true. So, for instance, in javascript a loop would look like this: countvar = 1; newstring = ; while (countvar < 5) document.write( <p>really </p> ); countvar = countvar + 1; document.write( <p> cute! </p> ); In the above code, the number 1 is first placed into the variable countvar. Then, while the value inside of countvar is less than 5, javascript will execute the code between and. Inside the loop, the word really is written to the html document and the value inside the countvar increases by 1 (to hold 2). Javascript then checks again: is the value in countvar < 5? If it is (if this condition is true) javascript writes the word really to the document again, and the value inside the countvar increases to 3. JavaScript checks again: Is the value in countvar < 5? JavaScript continues to execute the code between and until the condition (countvar < 5) is false (the value inside of countvar is no longer less than 5). That s a loop. Whatever code is between the and the will happen again and again until the condition is no longer true. Try it: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 7

"http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title> First Javascript </title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <script type = "text/javascript"> function JS(countvar) countvar = parseint(countvar); while (countvar < 5) document.write("<p> really </p>"); countvar = countvar + 1; document.write("<p> cute </p>"); </head> <body> <p id = "here" onclick = "JS('1')">Click to see the secret message </p> </html> Question: (DO NOT TRY THIS!!!) What would happen if you didn t include the line countvar = countvar + 1 inside the loop? Note 2: The line, countvar = parseint(countvar) converts a string to a number. In computer science, the numbers are located in one place and characters are located in another. so 5 actually would occur twice, once in the number area and once in the character area. To make absolutely sure we re using the 5 from the number area, we use ParseInt() to convert the 5 in the character area into the 5 in the number area. Another example of a loop would be: continuevar = true while (continuevar == true) count = count + 1 document.write( <p>because </p> ) continuevar = confirm("but Why?") In this case, the loop (all the code between and will continue to happen as long as the value inside of continuevar is true. So the value inside continuevar will change whenever the confirm box pops up and the user either hits ok (which is true), or cancel (which is false). Try this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> 8

<script type = "text/javascript"> function loopfun() continuevar = true while (continuevar == true) document.write("<p> Because </p>"); continuevar = confirm("but Why?") document.write("<p> Because I said so and that's final! </p>"); </head> <body> <p onclick = "loopfun()">why?</p> </html> Now let s put this all together. You re going to write a javascript that cycles through potential pictures for a background image on your page. When the user decides on an image (By clicking cancel when asked, Do you want to see another picture? ) the current image being displayed becomes the background image. <html> <head> <script type = "text/javascript"> ls = new Array() ls[0] = "bg1.jpg" ls[1] = "bg2.jpg" ls[2] = "bg3.jpg" ls[3] = "bg4.jpg" ls[4] = "bg5.jpg" ls[5] = "bg6.jpg" count = -1 function loopforbackground(idholder, idholder2) document.body.style.backgroundimage = document.getelementbyid(idholder2).innerhtml = " " continuevar = true while (continuevar == true) count = count + 1 if (count == ls.length) count = 0 document.images[idholder].src = ls[count] continuevar = confirm("do you want to see another picture?") document.body.style.backgroundimage = "url(\'" + ls[count] + "\')" document.getelementbyid(idholder2).innerhtml = "click here for other background options" </head> <body> 9

<img width = "500" height = "374" alt = "area in which pics will be displayed" id = "display" /> <h3 id = "firsttext" onclick = "loopforbackground('display','firsttext')"> Click here to see potential pics... </h3> </html> Note: What s going on here? document.body.style.backgroundimage = "url(\'" + ls[count] + "\')" Let s break it down. First, we re changing the body of the html document s background image. To change a background image, normally you d use url( backgroundpic.jpg ) In this case, the background image is inside the array at ls[count]. If we did this: bad: document.body.style.backgroundimage = "url( ls*count+ )" Javascript would try to set the background to an image called ls*count+ (and not what is inside ls*count+). Clearly that would not work because there is no image called ls*count+. So what we do instead is join together three different things: The string url( and ls*count+ and ) We join these three strings together using the + sign. At this point we d have: better, but still won t work: document.body.style.backgroundimage = "url( + ls*count+ + )" We re almost there, but the problem is the is a special character in javascript that indicates a quote. To show that we want the to be included in the string (and not an indicator of the beginning or ending of a string), we use the \ before it. Then Javascript just includes it in the string of characters. We end up with: good: document.body.style.backgroundimage = "url(\ + ls*count+ + \ )" Project 2: 1. Magic 8 (sort of): You re going to create a very odd version of the Magic 8 ball that sort of plays itself. With the physical magic 8 ball, someone asks a question and shakes a ball. The response that pops to the top of the ball is the answer to the question. So, for instance, the user might ask, Am I going to have 20 kids with the man of my dreams? and shake the ball, and an answer that might pop up would be, It appears so. For our automatic magic 8 ball game, you will create an array with a list of potential answers (like, Certainly, No Way!, It doesn t look good, etc.). You should also create an array (of equal length) of images that reflect the answer (a smiling face for Certainly, a dejected face for It doesn t look good, etc.). You will also need to create an array of questions. This array MUST NOT be the same length as the length of the array of answers. So far so good? You will also need 2 counters, one for the array of questions, and one for the array of answers (we will also use this same counter for the array of pictures). Now you will write a function that generates a random number between 0 and the length of the array of questions(remember how to generate a random number?), and uses that random number to display the question in the array associated with that random number. Your function will then generate another random number between 0 and the length of the array of the answers. It will use that random number to display both the text answer and the image associated with that random number. 10

Because this is a very bizarre Magic 8 ball game, your function will continue to generate new questions and new answers every 3000 milliseconds, and will start when the web page loads into the browser (<body onload = ) (You may need to make the time longer than 3000 milliseconds that s up to you). Make sure the html code in the web page includes a place for the question to be displayed, and for the answer and its associated image to be displayed. (An equally fun assignment would be to have an array of head images, a different length array of body images, and an even different length array of leg images, then have a function that displayed a random head on top of a random body on top of a random set of legs. Unfortunately, it requires hunting down a lot more images. If you want to do this instead, though, that s acceptable). 2. BlackJack (sort of) Overall Game: You re going to write a web page in which you get asked if you want another card continuously, and, if you say yes, a new card will be displayed in a different place on the web page. You re trying to make the cards come as close to but not go over 21. Steps: 1. Create an array of images. The images (pictures) should be of the numbers 1 through 11 (Note: the image of number 1 will go in the array at 0 because we always start our arrays at 0) 2. Write an html page with space for 12 images (probably a table with images in it.) Each image should have a unique id. 3. Create a counter variable. 4. Write a function GetCards() 5. Inside GetCards, write a confirm asking, do you want a card. 6. Write a loop. Your loop will continue while the answer from confirm is true 7. Inside your loop, generate a random number between 0 and the length of your image array. 8. Slightly challenging part: 1. Now (still inside your loop), you will create an if statement, that goes something like this: 2. If the counter is equal to 0, use the random number generated to display the image from the array (like we ve done before). You will display the image in the first id on the web page. 3. If the counter is equal to 1, you ll display the image in the second id on the web page. 4. If the counter is equal to 2, you ll display the image in the third id on the web page, 5. 6. If the counter is equal to 11, you ll display the image on the twelfth id on the web page. 9. Now you will use the confirm to ask, do you want another card. 10. End your loop 11. End your function Extra Credit (5 pts): Keep track of the total number generated by adding each random number generated together. If the number goes over 21, modify text on the page to say, You lose! Extra Extra Credit (10 pts): After the loop, but before the end of the function, generate a random number between 12 and 25 (The dealer s hand). If the dealer s random number is >21, modify text on the page to say, You win! Otherwise, check to see whose value is closer to 21 and modify text to report who won, accordingly. 11