LESSON 07 – ASSORTED TOPICS

 

GROUP WORK

 

PART 1 – THE ALERT FUNCTION

 

STEP 1 – Create a form containing one button.

 

STEP 2 – When the button is clicked, the function fun() should be executed in the head section of the file.

 

STEP 3 – Inside the fun() function, add the following line of code:

 

            alert("This rocks!");

 

            What happens when you click the button?

 

STEP 4 – Add another button to your form.  Make it run the same function.

 

            What happens when you click the 2nd button?

STEP 5 – Add a third button to your form. 

 

STEP 6 – When the third button is clicked, the function yuck() should be executed.

STEP 7 – Inside the yuck() function, use the alert function to display a different message.

PART 2 – EMTPY TEXT FIELD

 

STEP 1 – Create a form contain a text field and a button.

 

STEP 2 – When the button is clicked, the function valid() is executed.

 

STEP 3 – Inside the valid() function, check to see if the text field is empty.  Display an appropriate message such as “Empty baby!” or “Not empty baby!”.

 

Note: An empty text field contains the following string: ""

 

PART 3 – COMPARING DATA

 

STEP 1 – Create a form that contains two textfields and a button.

STEP 2 – When the button is clicked, the function check() should be executed.

 

STEP 3 – Inside the check() function, use an if statement to see if both text fields contain the same data.  Display either “They are different” or “They are the same” accordingly.