40 likes | 50 Views
Lecture Exercise ( Wk2). CS1301 Introduction To Computer Programming ( 11-12 Semester B) www.cs.cityu.edu.hk/~helena. Question 1 . Design a table in html In the HTML code below, all tag names are missed. Guess and fill in as many as possible.
E N D
Lecture Exercise ( Wk2) CS1301 Introduction To Computer Programming (11-12 Semester B) www.cs.cityu.edu.hk/~helena Question 1. Design a table in html In the HTML code below, all tag names are missed. Guess and fill in as many as possible. Hints:html, body, head, title, h2, b, br, table, td, tr Expected output: LectEx02_Q1_table.html < > < > < > CS1301 Tutorial Sections </ > </ > < > < >CS1301 Introduction to Computer Programming</ > < >Tutorial Sections:</ > < border="1"> < > < > Tutorial T01< /> Tutorial T02< /> Tutorial T03< /> Tutorial T04< /> </ > < > Mon 2:30pm< /> Wed 12:30pm< /> Tue 12:30pm< /> Tue 1:30pm< /> </ > < > CSC-D< /> CSC-I< /> CSC-B< /> CSC-C< /> </ > </ > </ > </ > </ >
<!-- and --> alert('Hello World!'); html comments document.write('Hello World!'); Question 2. MATCHING: Question 3. Write down 4 ways to include JavaScript in an HTML page: (i) Add JavaScript as ______________ (ii) Add JavaScript as ______________ (iii) Add JavaScript within _______ and _______ (iv) Add JavaScript as a ________________ Which parts below are using JavaScript? Highlightthem all. LectEx02_Q3_Greeting.html .. <body onload="alert('This is just a demonstration');"> <script type="text/javascript"> document.write("<span style='font-size:16pt'>Welcome to<b>WEEK 2 LECTURE!!</b></span>"); document.write("<br/> - - "); document.write(Date()); </script> <br/><br/> <a href="http://www.cs.cityu.edu.hk/~helena/">Go to Helena's page</a> <br/> <a href="javascript: alert(Date());">What time is it?</a> </body> .. This is just a demonstration
Question 4. Mary wants to create a page like : But it doesn’t work. Below is her code. It shows the result like . LectEx02_Q4_somethingWrong.html <html> <head> <title> Demo </title> </head> <body> three plus three is equal to six<br/> three is smaller than four and three is larger than two<br/> three+three=six<br/> three<four and three>two<br/> </body> </html> Wanted • * Html has some special code: • > - > • < - < • - [space] Wrong output Question 5. Try to understand the error(s) of the code below. Fix it. LectEx02_Q5_Debug.html 1 2 3 4 5 6 7 8 9 10 <!DOCTYPE..> <html> <head> <title>Demo</title> </head> <body onload="Alert("Hello World!");"> </body> </html> Syntax: the spelling and grammar of a programming language. * Question: I cannot see the above error window in my computer.Helena: Enable the error window in IE. [How? Read Hot Questions at the course web !! ]
Question 6: (To be done after slide #9 is covered) In the screens below, the value is doubled when "double" is clicked. Fill the missing code. LectEx02_Q6_DoubleInForm.html (a) <body> <form name="F001"> <input type="text" name="x" value=1 /> </form> <a href= </a> </body> LectEx02_Q6_DoubleInSpan.html (b) <body> <span id="x">1</span> <br/> <a href= </a> </body>