To Lecture Notes

IT 238 -- May 28, 2025

Practice Exercises

  1. The exercise from last time (May 21), by adding this line at the bottom of the body showing which questions were answered correctly, for example:
    1. Correct 2. Incorrect 3. Correct
    
    Answer: add this empty paragraph to the end of the body:
    <p id="details"></p>
    
    Modify the script.js file to look like this:
    function computeScore( ) {
        const correctAnswers = ["", "b", "c", "a"];
        var numCorrect = 0;
        var details = "";
        for(var i = 1; i <= 3; i++) {
            var isCorrect = false;
            for(var j = 1; j <= 3; j++) {
                var rb = document.getElementById("" + i + j);
                if (rb.checked && rb.value == correctAnswers[i]) {
                    numCorrect++;
                    isCorrect = true;
                }
            }
            var word = isCorrect ? "Correct" : "Incorrect";
            details += `${i}: ${word} `;
        }
        var outputPara = document.getElementById("numcorrect");
        outputPara.innerHTML = "Number correct: " + numCorrect;
        var detailsPara = document.getElementById("details");
        detailsPara.innerHTML = details;
    }
    
    function init( ) {
        var button1 = document.getElementById("btn1");
        button1.addEventListener("click", computeScore);
    }
    
    window.addEventListener("load", init);
    

Project 4

HTTP

Practice Quiz

Submission Forms

Form Validation -- Part A