MMDT1022 HTML II and Javascript
Week 4


Week 4

Read chapters 1 & 2 in the JavaScript textbook.  These chapters are introductory chapters on how to put javascript in your html code and how to do some basic things with JavaScript.

If using Internet Explorer, you may have to modify your security settings to allow Javascript to run correctly from your local hard drive or CD-ROM drive.


Sometimes it can be tricky when adding one number to another.  Data received from a prompt box is always interpreted as a string.  Therefore use the parseFloat function to convert to a number.

numerouno = prompt("Enter the first number:", "")
numerouno = parseFloat(numerouno)


Lab 4

Your instructor will show you an example to follow.

Part 1 - Using the document.write method, write two lines of text to the browser window.
Hint: output the <br /> to seperate the two lines from within the write method.

Part 2 - Put an image on your page.  When you click on the image, pop up an alert window.

Part 3 - Using a prompt method, have the user enter their name.  Provide the default name of  "John Doe" if they do not enter a name. Using an alert, repeat what they entered.

Part 4- Using prompt methods, have the user enter two numbers.  Respond with an alert with the two numbers multiplied together.  Check that numbers were indeed entered.

Grading Criteria Points
20
A folder created in the site root labeled "lab4" 1
Part 1 3
Part 2 4
Part 3 4
Part 4 6
Assignment in on time. 2