Quiz 3: EECS 101
  1. (5 points) What does the page look like when it comes up in the browser (draw it)? What happens when I push the button?

    <head><script language=JavaScript>
    function dostuff() {
    document.bgColor = "blue";
    document.myform.intern.value = "Lewinsky";
    }
    </script></head><body><form name=myform>
    <input type=text value="Monica" name=intern>
    <input type=button value="White House" onClick="dostuff(); return true">
    </form></body>
    

    Before:



    After:

  2. (5 points) Give a complete HTML source file (including JavaScript) in which there are three text fields, labeled alpha, beta, and gamma and two buttons, labeled compare and zap. When I push the compare button, the gamma field should be set to the larger of the two values in alpha and beta (you may assume that they are numbers). When I push zap, zeros appear in all three text fields.

    <head>
    <script>
    function compare() {
        if (parseInt(document.myform.alpha.value) >
                parseInt(document.myform.beta.value) ) {
                     document.myform.gamma.value = document.myform.alpha.value;
        } else {
                     document.myform.gamma.value = document.myform.beta.value;
        }
    }
    function zap() {
        document.myform.alpha.value = 0;
        document.myform.beta.value = 0;
        document.myform.gamma.value = 0;
    }
    </head>
    <body>
    <form name=myform>
    alpha<input type=text name=alpha><br>
    beta<input type=text name=beta><br>
    gamma<input type=text name=gamma><br>
    <input type=button name="Compare" onClick="compare();">
    <input type=button name="Zap" onClick="zap();">
    </form>
    
    </body>