To Lecture Notes

IT 130 -- 2/8/10

 

Review Questions

  1. Where do you put JavaScript statements in an HTML file?
     
    Ans: Put the name of the event handler in the onclick attribute. Put the definition of the event handler within script tags in the head section.
     
  2. 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.
     
  3. Write a JavaScript statement to display an alert box that contains File not found.
     
    Ans: Put the JavaScript code alert('File not found.'); in an onclick attribute.
     
  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.
     
  7. Ans: <input type=button name=btnB value=Push Me />
     
  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.  
    3. What is the name of the form containing the textboxes and button?
       
      Ans: frmTemperature
       
    4. What does this statement mean?
       
        var f, c;
         
      Ans: It declares the variables f and c.
       
    5. Which JavaScript function converts a character string into a number?
       
      Ans: parseFloat
       
    6. 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?
       
    7. What is an event handler?
       
      Ans: It is a function that is executed when an event occurs like a button click.

  9. The following code is supposed to create a button that is 6 inches by 2 inches with caption Push Me. When the button is clicked, the caption on the button is supposed to change to to I've been clicked. Correct the mistakes using PSPad and FireFox.
    <html>
    
    <head>
    <title>Big Button
    <style type=text/css>
    body, input  { color:maroon;
                   background-color:beige;
                   font:Comic Sans MS; 
                   fontsize:300%; }
    input        { width:6.0in; height:2.0in; }
    <script type=txt/javascript>
    function changeCaption
    {
        document.frmBigButton.btnClickMe.value = I've been clicked;
    
    </script>
    </head>
    
    <body>
    
    <form name=frmClickMe>
    </form> 
    <p><input type=button 
              name=btn Click Me 
              value=Click Me
              onclick=changecaption( ); /></p>
    
    </body>
    </html>
    
    Ans: Here is a webpage that does this.

 

Literals, Variables, and Operators

 

Practice Problems

 

Project 4