Events 如何在注册时输出coment,并在选中时从输出中去掉“请选中复选框”

Events 如何在注册时输出coment,并在选中时从输出中去掉“请选中复选框”,events,output,Events,Output,我试图让它像图片一样工作,但不知怎么的,它的一部分不工作了,我无法找出我做错了什么 // Function called when events occur. // Function reports the event type and target. function reportEvent(e) { 'use strict'; // Get the event object: if (typeof e ==

我试图让它像图片一样工作,但不知怎么的,它的一部分不工作了,我无法找出我做错了什么

    // Function called when events occur.
    // Function reports the event type and target.
    function reportEvent(e) {
        'use strict';
     
        // Get the event object:
        if (typeof e == 'undefined') e = window.event;
     
        // Get the event target:
        var target = e.target || e.srcElement;
       
        // Establish the output message:
        var msg = target.nodeName + ': ' + e.type + '\n';
       
        // Add the output to the textarea:
        U.$('output').value += msg;
       
                   
    } // End of reportEvent() function.
     
    // This function is called when the form is submitted.
    // It adds and removes event handlers
     
    // and returns false to prevent submission.
    function setHandlers() {
        'use strict';
     
        // List of possible events:
        var events = ['mouseover', 'mouseout', 'click', 'keypress', 'blur'];
                   
        // Add or remove event handlers accordingly:
        for (var i = 0, count = events.length; i < count; i++) {
            var checkbox = U.$(events[i]); // Get the element.
            if (checkbox.checked) { // Is it checked?
               U.addEvent(document, events[i], reportEvent);
            } else {
                U.removeEvent(document, events[i], reportEvent);
            }
                                                   
        } // End of FOR loop.
        // Clear the output textarea:
     
    if (checkbox.checked) {
                    U.$('output').value = '';
                    } else {
                    U.$('output').value = 'please select a checkbox'
                    }
        // Return false to prevent submission:
        return false;
       
    } // End of setHandlers() function.
     
    // Establish functionality on window load:
    window.onload = function() {
        'use strict';
        U.$('theForm').onsubmit = setHandlers;
    };