Title: Workshop Assignment
1WorkshopAssignment 2
2Assignment Two
- Using the two programs below that we discussed in
class... - ...create a single program that uses the ltformgt
structure to say, good morning, or good day,
or good evening
3Selection
lthtmlgt ltbodygt ltscript type"text/javascript"gt var
d new Date() var time d.getHours() if (time lt
10) document.write("ltbgtGood morning!lt/bgt") el
se if (timegt10 timelt16) document.write("ltbgtGo
od day!lt/bgt") else document.write("ltbgtGood
evening!lt/bgt") lt/scriptgt lt/bodygt lt/htmlgt
4Functions
lthtmlgt ltheadgt ltscript type"text/javascript"gt func
tion displaymessage() alert("Hello
World!") lt/scriptgt lt/headgt ltbodygt ltformgt ltinput
type"button" value"Click me!" onclick"displayme
ssage()" gt lt/formgt lt/bodygt lt/htmlgt
5Hints
- Start with Hello World program
- Get the next example programs to work
- Break things into steps and test
- Distinguish between ltheadgt and ltbodygt placement
- Instead of document.write (...) you will use
alert (...) - play with JavaScripthttp//www.w3schools.com/js
/js_howto.asp
6Hello World
lthtmlgt ltbodygt ltscript type"text/javascript"gt docu
ment.write("Hello World!") lt/scriptgt lt/bodygt lt/htm
lgt
7Have A Happy Thanksgiving
See You Next Monday, 11/27