To Notes

IT 130 -- 11/6/08

 

Practice Problems

  1. Write a JavaScript statement that assigns the value of the textbox txtSource to the variable x.

    x = parseFloat(document.frmMain.txtSource.value);

  2. Write a JavaScript statement that assigns the value of the variable x to the textbox txtTarget.

    document.frmMain.txtTarget.value = x;

  3. The following error messages appear in the FireFox JavaScript Error Console. What do they mean?

    1. document.frmMain.txtA has no properties

      Ans: The spelling of txtA does not match the spelling defined for the name of the input tag.

    2. document.frmmain has no properties

      Ans: The spelling of frmmain does not match the spelling of the name defined in the form tag.

    3. computeMass is not defined

      Ans: The name of the function computeMass defined in the JavaScript function definition does not match with the name used in the onclick attribute of the button.

    4. missing } after function body

      Ans: Just what is says. There is a right brace missing to end the definition of the JavaScript function body.

    5. missing ; before statement

      var x y;

      Ans: var x y; should be changed to var x, y;

  4. What is the output? For strings, s < t if s precedes t in alphabetic order

    var x = "cat", y = "dog";
    if (x + y > y + x)
    {
         System.out.println("yes");
    }
    else
    {
         System.out.println("no");
    }
    
    Ans:
            x + y > y + x
    "cat" + "dog" > "dog" + "cat"
         "catdog" > "dogcat"
                 false
    
    Therefore the else part of the else-if statement is executed to print no.

  5. Construct the variable trace and predict the output:

    x = 5;
    y = 4;
    a = 3;
    if (x + y >= 9)
    {
        a = 3 * a + 1;
    }
    else
    {
        a = 2 * a + 3;
    }
    document.writeln(a);
    
    Variable Trace:

    x x x x + y >= 9
    5 4 3 true
    5 4 10 true

    Output: 10

  6. Write an HTML/JavaScript application with two radio buttons with values "Pass" and "Fail". If the pass button is clicked, show the happy image. If the fail button is clicked, show the sad image.

    Ans: See this PassFail Example.

  7. What are the components of this sample URL:

http is the protocol.

org is the top level domain.

activa is the secondary domain.

news is the third level domain.

www is the server name.

march is the folder.

news.htm is the HTML page name.

 

The Steps to Obtaining a Webpage from the Server

  1. The user enters www.depaul.edu/~sjost/it130/index.htm in the browser URL textbox on the host PC.

  2. The browser extracts www.depaul.edu from the URL and sends it to the local domain-name server.

  3. The domain-name server looks up this name in its table. If it finds its IP address, it sends it back to the host PC. It the name it not in its table, it forwards the name to another domain name server according to its router directions.

  4. When a domain name server is found that can translate www.depaul.edu, it does so: www.depaul.edu translates to the IP address 140.192.23.180 and sends it back to the host.

  5. The host sends a request for the webpage ~sjost/index.htm to the depaul server at 140.192.23.180.

  6. The server sends the webpage ~sjost/index.htm back to the host.

  7. The browser on the host machine displays the page.

Open a command window and enter ipconfig to get the IP address of your PC.

 

Review for Final Exam

 

Examples for Project Proj6

 

Project Proj6