Skip to main content.

Lab 7: JavaScript

Page Contents:

Goals

After completing this lab, you should be able to

--- JavaScript Lab FAQ ---

JavaScript

You can and should look at the examples.

See the JavaScript resources on the Resources page on the Wiki.

Set Up

How old are you? (35 pts)

Create a new HTML page called age.html

Write the HTML and the JavaScript that computes how old you are in years and days. The page should display your birthdate as well as your age. (This can just be a hardcoded birthday, not from user input; however, most of your code should be such that someone need only to substitute their own birthday once and the code will still work correctly.)

Make sure your code works whenever a person accesses this page, not just today or this term.

Notes:

Toggle Color (30 pts)

Add a button to your CS335 home page that toggles the color of your h2 elements between the original color and another color.

Consider ...

Form Validation (35 pts)

Copy your Lab4 sandwich form to a file called javascript_sandwich.html.

Add JavaScript to your form so that it requires that the user chooses a value for base and cheese before submitting the form. (No cheese is a valid choice.)

Take It to the Next Level

Find an example of JavaScript on the Web and apply it to one of your Web pages. You can find examples at w3schools and by looking on many web pages. Somehow link or let me know that you did this task.

Submission

Add links to your age.html and javascript_sandwich.html pages under the "Submissions" heading on your cs335/index.html page.

Grading (100 pts)

This lab is due tonight at 11:59 p.m.