CSPE61 Assignment1
CSPE61 Assignment1
CSPE61 Assignment1
Assignment # 01
CSPE61 – Web Technology and its Applications ( Program Elective )
1. Design the form as shown below and enter your date of birth.
Write a Java script program to display your age and the number of
days remaining until your next birthday in a dialog box, when the
OK button is clicked.
7. Write a Web page that enables the user to play the game of 15(15
puzzle). There is a 4-by- 4 board (implemented as an XHTML
table) for a total of 16 slots. One of the slots is empty. The other
slots are occupied by 15 tiles, randomly numbered from 1 through
15. Any tile next to the currently empty slot can be moved into the
currently empty slot by clicking on the tile. Your program should
create the board with the tiles out of order. The user’s goal is to
arrange the tiles into sequential order row by row. Using the
DHTML object model and the onclick event, write a script that
allows the user swap the positions of the open position and an
adjacent tile. [Hint: The onclick event should be specified for each
table cell.] Also modify your solution to determine when the game
is over, then prompt the user to determine whether to play again. If
so, scramble the numbers.
8. Write a Java script that reads several lines of text from the
keyboard and prints a table indicating the number of occurrences of
each letter of the alphabet in the text. For example, the phrase
To be, or not to be: that is the question:
contains one “a,” two “b’s,” no “c’s,” etc.
Also write a script that reads several lines of text and prints a
table indicating the number of one-letter words, two-letter words,
three-letter words, etc. appearing in the text, in a tabular form. For
example, the phrase Whether 'tis nobler in the mind to suffer
contains
Word Length Occurrences
1 0
2 2
3 1
4 2(including ‘tis)
5 0
6 2
7 1
9. Write a Java script that inputs a telephone number as a string in
the form (555) 555-5555. The script should use String method split
to extract the area code as a token, the first three digits of the
phone number as a token and the last four digits of the phone
number as a token. Display the area code in one text field and the
seven-digit phone number in another text field.
10. Write an error handler that changes the alt text of an image to
“Error Loading” if the image loading is not completed.
15. Add two elements to the web page that users can click. Use the
deitel.gif image file as the first element. When the user clicks the
image, display an alert dialog box with the text “you clicked the
image.” For the second element, create a one-row table containing
a text string. Set the table border to one. When the user clicks the
table element, display an alert dialog box containing “you clicked
the table.” In the two accompanying functions, set each event
object to true.
________________________________________________________