To Notes

IT 130 -- 10/16/08

 

Review Questions

  1. How do you display an alert box that displays "Waz up?"

    Ans: Put the JavaScript code alert('Waz up?'); in an onclick attribute.

  2. Where do you put JavaScript statements in an HTML file?

    Ans: In the onclick attribute. In this lecture we will see that JavaScript can also go within script tags in the head or in the body.

  3. Give four places where JavaScript can display output.

    Ans: (1) In an alert box, (2) in the status bar, (3) in a text box or (4) in a button caption.

  4. Name six attributes that can be used on an input tag.

    Ans: type, name, size, value, onclick, style.

  5. Write an HTML input tag for a textbox with name txtA, size 10 and initial text "0".

    Ans: <input type="text" name="txtA" size="10" value="0" />

  6. Write an HTML input tag for a button with name btnB and caption "Push Me".

    Ans: <input type="button" name="btnB" value="Push Me" />

  7. Create a button that is 6 inches by 2 inches with caption "Push Me".

    Ans: Here is a webpage that does this.

  8. Look at this Temperature1 Example, right click on the document and select View Source. Then answer these questions:

    1. How do you create a source code comment in HTML?

      Ans: Place it between <!-- and -->.

    2. What is the name of the form containing the textboxes and button?

      Ans: frmTemperature

    3. What does this statement mean?

        var f, c;

      Ans: It declares the variables x, y and t.

    4. Which JavaScript function converts a character string into a number?

      Ans: parseFloat

    5. What does this JavaScript statement do?

        f = (9 * c / 5) + 32;

      Ans: It computes the Fahrenheit value that corresponds to the Celsius value c and assigns it to f.

 

Using JavaScript for Output

 

Literals, Variables, and Operators

 

Variable Trace Problems

 

Event Handlers

 

Practice Problems