DISC 3371

SAMPLE FINAL EXAM

  1. (30 points) Using HTML only, create the following page:

    TITLE in BOLDFACE
    r1 r2 r3 r4 r5 r6
    A checkbox
    1st item this row 2nd item this row

  2. (30 points) Write the HTML necessary to collect the data shown on the form below.

    LAST NAME
    FIRST NAME
    ADDRESS
    CITY
    SSN
    PASSWORD
    PRODUCT CODE

    Each of the text fields above is 50 characters in length.When the user clicks the submit button, a VBScript routine should:

    1. Examine each text field (last name, first name, address and city) and replace any occurrences of characters: / or \ or + with blanks. Use only one function to perform this check
    2. Check social security number for numeric values and that the value entered contains 9 digits
    3. Check the password for validity using the following rule:

      The sum of the six digits of the password must add up to a value of 20

    4. The product code must have three characters, the first must be the letter "A" (caps or lower case)

    If errors are detected when checking items 2-4 above, display a message box and request the user re-enter the data. After performing step 1 above AND all data edits (items 2-4 above) are OK, submit the form to: http://www.fred.com/check.cgi

  3. (40 points) Consider the following HTML frame structure:

     

    FRAME 1
    1. ADD 1 to counter
    2. ADD 2 to counter
    3. ADD 3 to counter
    4. ADD 4 to counter
    5. ADD 5 to counter
    FRAME 2

    COUNTER = 0

    FRAME 3

    This is just HTML -- the button does not work. See answer below

    The value of "counter" is located in a hidden form value which is part of Frame 3. This hidden value is initially zero. When the user clicks on one of the links on Frame 1:

    1. the value of counter is incremented by the value shown on the link (i.e., 1,2,3,4, or 5)
    2. Frame 2 is then recreated with the new value of counter displayed

    If the user clicks the Reset button in Frame 3, the value of counter is set to zero and Frame 2 recreated.


    Answer:

    Click here to see the whole thing work.

    The answer is laid out in five frames:

    At the top is f3371ans.htm. This htm file contain is a frameset like this:

    <html>
    <frameset cols="300,*">
     <frame src="fframe0.htm">
     <frame src="fframe2.htm">
    </html>
    

    fframe0.htm is a frameset that creates two rows:

    <html>
    <frameset rows="300,*">
     <frame src="fframe1.htm">
     <frame src="fframe3.htm">
    </html>
    

    Frame 1 (i.e., fframe1.htm) is:

    <html>
    <body>
    <p> <p><center>FRAME 1</center>
    <ol>
    <li><a href="fframe1.htm" language="VBSCRIPT" onclick=
    'dim a,b:
    set a=top.frames(0).frames(1).document.f3form:
    set b=top.frames(1):
    a.counter.value=a.counter.value +1:
    b.location.href="fframe2.htm":'>ADD 1 to counter</a>
    <li><a href="fframe1.htm" language="VBSCRIPT" onclick=
    'dim a,b:
    set a=top.frames(0).frames(1).document.f3form:
    set b=top.frames(1):
    a.counter.value=a.counter.value +2:
    b.location.href="fframe2.htm":'>ADD 2 to counter</a>
    <li><a href="fframe1.htm" language="VBSCRIPT" onclick=
    'dim a,b:
    set a=top.frames(0).frames(1).document.f3form:
    set b=top.frames(1):
    a.counter.value=a.counter.value +3:
    b.location.href="fframe2.htm":'>ADD 3 to counter</a>
    <li><a href="fframe1.htm" language="VBSCRIPT" onclick=
    'dim a,b:
    set a=top.frames(0).frames(1).document.f3form:
    set b=top.frames(1):
    a.counter.value=a.counter.value +4:
    b.location.href="fframe2.htm":'>ADD 4 to counter</a>
    <li><a href="fframe1.htm" language="VBSCRIPT" onclick=
    'dim a,b:
    set a=top.frames(0).frames(1).document.f3form:
    set b=top.frames(1):
    a.counter.value=a.counter.value +5:
    b.location.href="fframe2.htm":'>ADD 5 to counter</a>
    </ol>
    </body>
    </html>
    

    Frame 2 (i.e., fframe2.htm) is:

    <html>
    <head>
    <script language="VBSCRIPT">
    <!---
    sub f2_onload
    document.clear
    document.open
    document.write "<html><body><font size='5'><p><center>Frame 2<p>"
    document.write "COUNTER = "
    document.write cstr(top.frames(0).frames(1).f3form.counter.value)
    document.write "</center></body></html>"
    document.close
    end sub
    --->
    </script>
    </head>
    <body onload="f2_onload">
    </body>
    </html>
    

    Frame 3 (i.e., fframe3.htm) is:

    <html>
    <head>
    <script language="vbscript">
    <!---
    sub makezero_onClick
    window.document.f3form.counter.value=0
    top.frames(1).location.href="fframe2.htm"
    end sub
    --->
    </script>
    </head>
    <body>
    <center>FRAME 3<p>
    <form name="f3form">
    <input type="button" value="Reset Counter to Zero" name="makezero"></center>
    <input type="hidden" name="counter" value="0">
    </form>
    </body>
    </html>