萤火虫说不是功能

1 html javascript forms firebug

<script type = "text/javascript">
        var First_Array = new Array();
        function reset_Form2() {document.extraInfo.reset();}
        function showList1() {document.getElementById("favSports").style.visibility="visible";}
        function showList2() {document.getElementById("favSubjects").style.visibility="visible";}
        function hideProceed() {document.getElementById('proceed').style.visibility='hidden';}

    function proceedToSecond ()
    {
        document.getElementById("div1").style.visibility="hidden";
        document.getElementById("div2").style.visibility="visible";
        document.getElementById("favSports").style.visibility="hidden";
        document.getElementById("favSubjects").style.visibility="hidden";
    }

    function backToFirst () {
        document.getElementById("div1").style.visibility="visible";
        document.getElementById("div2").style.visibility="hidden";
        document.getElementById("favSports").style.visibility="visible";
        document.getElementById("favSubjects").style.visibility="visible";
    }

    function reset_Form(){
        document.personalInfo.reset();
        document.getElementById("favSports").style.visibility="hidden";
        document.getElementById("favSubjects").style.visibility="hidden";
    }

    function isValidName(firstStr) {
        var firstPat = /^([a-zA-Z]+)$/;

        var matchArray = firstStr.match(firstPat);
        if (matchArray == null) {
            alert("That's a weird name, try again");
            return false;
        }

        return true;
    }

    function isValidZip(zipStr) {
        var zipPat =/[0-9]{5}/;
        var matchArray = zipStr.match(zipPat);
        if(matchArray == null) {
            alert("Zip is not in valid format");
            return false;
        }
        return true;
    }

    function isValidApt(aptStr) {
        var aptPat = /[\d]/;
        var matchArray = aptStr.match(aptPat);
        if(matchArray == null) {
            if (aptStr=="") {
                return true;
            }
            alert("Apt is not proper format");
            return false;
        }

        return true;
    }

    function isValidDate(dateStr) {
        //requires 4 digit year:

        var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

        var matchArray = dateStr.match(datePat);
        if (matchArray == null) {
            alert("Date is not in a valid format.");
            return false;
        }
        return true;
    }

    function checkRadioFirst() {
        var rb = document.personalInfo.salutation;

        for(var i=0;i<rb.length;i++) {
            if(rb[i].checked) {
                return true;
            }
        }
        alert("Please specify a salutation");
        return false;
    }

    function checkCheckFirst() {
        var rb = document.personalInfo.operatingSystems;

        for(var i=0;i<rb.length;i++) {
            if(rb[i].checked) {
                return true;
            }
        }
        alert("Please specify an operating system") ;
        return false;
    }

    function checkSelectFirst() {
        if ( document.personalInfo.sports.selectedIndex == -1)
        {
            alert ( "Please select a sport" );
            return false;
        }
        return true;
    }

    function checkRadioSecond() {
        var rb = document.extraInfo.referral;

        for(var i=0;i<rb.length;i++) {
            if(rb[i].checked) {
                return true;
            }
        }

        alert("Please select form of referral");
        return false;
    }

    function checkCheckSecond() {
        var rb = document.extraInfo.officeSupplies;

        for(var i=0;i<rb.length;i++) {
            if(rb[i].checked) {
                return true;
            }
        }
        alert("Please select an office supply option");
        return false;
    }

    function checkSelectSecond() {
        if ( document.extraInfo.colorPick.selectedIndex == 0 ) {
            alert ( "Please select a favorite color" );
            return false;
        }
        return true;
    }

    function check_Form(){
        var retvalue = isValidDate(document.personalInfo.date.value);
        if(retvalue) {

            retvalue = isValidZip(document.personalInfo.zipCode.value);
            if(retvalue) {

                retvalue = isValidName(document.personalInfo.nameFirst.value);
                if(retvalue) {

                    retvalue = checkRadioFirst();
                    if(retvalue) {

                        retvalue = checkCheckFirst();
                        if(retvalue) {

                            retvalue = checkSelectFirst();
                            if(retvalue) {

                                retvalue = isValidApt(document.personalInfo.aptNum.value);
                                if(retvalue){
                                    document.getElementById('proceed').style.visibility='visible';

                                    var rb = document.personalInfo.salutation;

                                    for(var i=0;i<rb.length;i++) {
                                        if(rb[i].checked) {
                                            var salForm = rb[i].value;
                                        }
                                    }

                                    var SportsOptions = "";
                                    for(var j=0;j<document.personalInfo.sports.length;j++){
                                        if ( document.personalInfo.sports.options[j].selected){
                                            SportsOptions += document.personalInfo.sports.options[j].value + " ";
                                        }
                                    }

                                    var SubjectsOptions= "";
                                    for(var k=0;k<document.personalInfo.subjects.length;k++){
                                        if ( document.personalInfo.subjects.options[k].selected){
                                            SubjectsOptions += document.personalInfo.subjects.options[k].value + " ";
                                        }

                                    }

                                    var osBox = document.personalInfo.operatingSystems;
                                    var OSOptions = "";
                                    for(var y=0;y<osBox.length;y++) {
                                        if(osBox[y].checked) {
                                            OSOptions += osBox[y].value + " ";
                                        }
                                    }


                                    First_Array[0] = salForm;
                                    First_Array[1] = document.personalInfo.nameFirst.value;
                                    First_Array[2] = document.personalInfo.nameMiddle.value;
                                    First_Array[3] = document.personalInfo.nameLast.value;
                                    First_Array[4] = document.personalInfo.address.value;
                                    First_Array[5] = document.personalInfo.aptNum.value;
                                    First_Array[6] = document.personalInfo.city.value;
                                    for(var l=0; l<document.personalInfo.state.length; l++) {
                                        if (document.personalInfo.state.options[l].selected) {
                                            First_Array[7] = document.personalInfo.state[l].value;
                                        }
                                    }
                                    First_Array[8] = document.personalInfo.zipCode.value;
                                    First_Array[9] = document.personalInfo.date.value;
                                    First_Array[10] = document.personalInfo.phone.value;
                                    First_Array[11] = SportsOptions;
                                    First_Array[12] = SubjectsOptions;
                                    First_Array[13] = OSOptions;

                                    alert("Everything looks good.");
                                    document.getElementById('validityButton').style.visibility='hidden';
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    /*function formAction2() {
        var retvalue;
        retvalue = checkRadioSecond();
        if(!retvalue) {
            return retvalue;
        }

        retvalue = checkCheckSecond();
        if(!retvalue) {
            return retvalue;
        }

        return checkSelectSecond() ;
    }   */
</script>
Run Code Online (Sandbox Code Playgroud)

这只是代码的一个示例,还有更多的功能,但我认为错误可能与周围的代码有关.我完全不知道为什么,因为我知道所有周围的函数都执行,并且填充了First_Array.

但是当我单击Proceed to Second按钮时,onclick属性不会执行,因为Firebug说proceedToSecond不是函数

按钮代码:

<input type="button" id="proceed" name="proceedToSecond" onclick="proceedToSecond();" value="Proceed to second form">
Run Code Online (Sandbox Code Playgroud)

Wes*_*May 5

我有同样的问题,这是因为你有一个与你的功能同名的表格.JavaScript似乎无法区分这两者,因此您得到"非函数"错误.