Computer Science 180
Web Design
Fall 2011, Siena College
It's back to building web pages this week, as you will make use of the new techniques we have been looking at in class: HTML Forms and JavaScript event handlers.
You may work alone or with a partner for all parts of this lab.
In Lab: Experimenting with Form Controls
For this first part, you will use the new HTML elements corresponding to form controls to build a form that looks like this:
Strive to make the form appear precisely as in the image above. It should also meet these requirements:
<form>
element with an
empty action attribute.
In Lab: JavaScript Practice
Create a page that contains a simple HTML table with a header row, at least 3 regular rows, and at least 2 columns per row, and a caption.
Use buttons and JavaScript event handlers and functions to accomplish the following:
<caption>
element controls its position relative to the
table.) Note: this seems to fail in Firefox - test it in other browsers!
In Lab: Some Additional JavaScript Functionality
The w3schools.com page JavaScript How To shows some new bits of JavaScript functionality:
<script>
element within the <body>
of
a document.
Create a page similar to the one in the demo, but which updates the date string to the current time each time the mouse is clicked on the displayed date.
Note: if you need to include double quotes inside the string you pass to document.write (and you do), you can put that string in single quotes instead:
document.write('<p class="snoopy">');
In Lab: Accessing Form Data from JavaScript
Even before we start to consider how to submit forms with submit buttons, we can explore how to make use of the data in form controls using JavaScript event handlers.
Try out this example: helloperson.html. Most of this is familiar from previous examples, but there are a couple of items you have not yet seen.
We can take this a step further and display only the form when the page is first rendered, then only the message after the button has been clicked, as in this example: helloperson2.html.
<div>
,
essentially just a placeholder in the page, with a name we can look
up, where we can later place something else.
<form>
element an id, so we can look it
up using document.getElementById.
<div>
, so we enclose the text we wish to
display in a <p>
element.
<form>
element to ""
- the empty string - which
makes its contents empty.
The effect is to place what looks like a brand new message onto the page, and to remove the form from the page. We will look at all of them in upcoming examples. For now, the .value will be enough to do the following.
Mad Libs
Create a simple "Mad Lib" (spend a couple minutes looking at search results on this if you are not familiar with the concept) where you first display at least 5 text inputs labelled appropriately to inform your users of the kind of word or words required for each. When a button is pressed, the form is hidden and a silly message is displayed, using the values entered in the form (and highlighted in red) in the appropriate places.
Building Another Form
Develop a form that could be used to gather food preferences for the guests of a party. One possibility is a "pizza and wings" party. In this case, the form might ask guests how many slices of pizza they want and which of a collection of toppings they like, how many wings they expect to eat and their preference for how spicy they like wings, and whether they prefer diet or regular soda. You may use this example or come up with something with similar complexity using the same kinds of form controls needed here. You need not provide any JavaScript event handlers or submission handling capabilities - just the form layout.
Submitting Your Work
Before 1:30 PM, Monday, October 31, 2011, submit your files for grading. There are three things you need to do to complete the submission: (i) make sure your pages are uploaded properly to the class web space and are available at your URI, (ii) update your main index on the class web space to have links to all documents you have created for this lab, and (iii) email a copy of your files to me at jteresco AT siena.edu. If you worked with a partner on any of the items, you need only upload to the account of one of the team members, but each team member should link to the pages on his or her own main index. Make sure all of your pages validate properly as XHTML Strict.
Grading Sheet
This lab is worth 30 points, which are distributed as follows:
> Feature | Value | Score |
Required Documents | ||
Web Design Race Entry Form | 4 | |
JavaScript Practice Table | 4 | |
Date Display Page | 4 | |
Mad Lib Page | 6 | |
Party Food Preference Form | 6 | |
Style | ||
XHTML documents pass validation | 3 | |
Formatting of HTML text | 1 | |
Submission | ||
Main index updated | 1 | |
Email submission | 1 | |
Total | 30 | |