我找不到功能名称

时间:2016-03-19 19:27:39

标签: javascript html function button

我正在为我的FRC团队编写一个程序,并遇到一个按钮问题。它应该通过SendData7()OnClick激活函数SendData1()。但是当我单击按钮时,程序会卡在SendData4()上。我该如何解决这个问题?



<form>
    <button style="width: 100px; height: 50px; position: relative; bottom: 150px;" type="button" onClick="sendData4();sendData1();sendData2();sendData3();sendData5();sendData6();sendData7();">Submit</button>
</form>

<script type="text/javascript">
    function sendData4() {
        alert("Hey");
        var rootRef = new Firebase('https://frc-data.firebaseio.com/Round');
        var usersRef = rootRef.child(roundNumber+"/"+allianceColor);
        usersRef.set({
            AllianceScore: allianceScore,
            AllianceFouls: fouls,
            RP: ARP,
        }
        ,function(error) {
            if (error) {
                alert("Data4 could not be saved." + error);
            } else {
                alert("Data4 saved successfully.");
            }
        });
    }
    function sendData1() {
        alert("Hey");
        if (attempt1 >= 1) {
            var percent1 = (Math.round(((upper1)/(attempt1))*100)/100)
        } else {
            var percent1 = 0;
        }
        var defenses1 = ((FT1D1)+(ST1D1)+(FT1D2)+(ST1D2)+(FT1D3)+(ST1D3)+(FT1D4)+(ST1D4)+(FT1D5)+(ST1D5))
        var rootRef = new Firebase('https://frc-data.firebaseio.com/Round');
    	var usersRef = rootRef.child(roundNumber+"/"+allianceColor+"/"+T1Number);
    	usersRef.set({
    		AutoLower: autoLow1,
    		AutoUpper: autoUpper1,
    		AutoReached: autoDR1,
    		AutoCrossed: autoDC1,
    		Upper: upper1,
    		Attempt: attempt1,
    		PercentMade: percent1,
    		Lower: low1,
    		StealsBlocks: stealBlock1,
    		Defenses: defenses1,
    		Challenged: TT1C,
    		Scaled: TT1S,
    		YellowCards: yellow1,
    		RedCards: red1,
    		TechFouls: tech1,
    		EStopDisabled: T1ESD,
        }
        ,function(error) {
            if (error) {
                alert("ATeam1 could not be saved." + error);
            } else {
                alert("ATeam1 saved successfully.");
            }
        });
    }
    function sendData2() {
        alert("Hey");
        if (attempt2 >= 1) {
            var percent2 = (Math.round(((upper2)/(attempt2))*100)/100);
        } else {
            var percent2 = 0;
        }
        var defenses2 = ((FT2D1)+(ST2D1)+(FT2D2)+(ST2D2)+(FT2D3)+(ST2D3)+(FT2D4)+(ST2D4)+(FT2D5)+(ST2D5))
        var rootRef = new Firebase('https://frc-data.firebaseio.com/Round');
    	var usersRef = rootRef.child(roundNumber+"/"+allianceColor+"/"+T2Number);
    	usersRef.set({
    		AutoLower: autoLow2,
    		AutoUpper: autoUpper2,
    		AutoReached: autoDR2,
    		AutoCrossed: autoDC2,
    		Upper: upper2,
    		Attempt: attempt2,
    		PercentMade: percent2,
    		Lower: low2,
    		StealsBlocks: stealBlock2,
    		Defenses: defenses2,
    		Challenged: TT2C,
    		Scaled: TT2S,
    		YellowCards: yellow2,
    		RedCards: red2,
    		TechFouls: tech2,
    		EStopDisabled: T2ESD,
        }
        ,function(error) {
            if (error) {
                alert("ATeam2 could not be saved." + error);
            } else {
                alert("ATeam2 saved successfully.");
            }
        });
    }
    function sendData3() {
        alert("Hey");
        if (attempt3 >= 1) {
            var percent3 = (Math.round(((upper3)/(attempt3))*100)/100);
        } else {
            var percent3 = 0;
        }
        var defenses3 = ((FT3D1)+(ST3D1)+(FT3D2)+(ST3D2)+(FT3D3)+(ST3D3)+(FT3D4)+(ST3D4)+(FT3D5)+(ST3D5))
        var rootRef = new Firebase('https://frc-data.firebaseio.com/Round');
    	var usersRef = rootRef.child(roundNumber+"/"+allianceColor+"/"+T3Number);
    	usersRef.set({
    		AutoLower: autoLow3,
    		AutoUpper: autoUpper3,
    		AutoReached: autoDR3,
    		AutoCrossed: autoDC3,
    		Upper: upper3,
    		Attempt: attempt3,
    		PercentMade: percent3,
    		Lower: low3,
    		StealsBlocks: stealBlock3,
    		Defenses: defenses3,
    		Challenged: TT3C,
    		Scaled: TT3S,
    		YellowCards: yellow3,
    		RedCards: red3,
    		TechFouls: tech3,
    		EStopDisabled: T3ESD,
        }
        ,function(error) {
            if (error) {
                alert("ATeam3 could not be saved." + error);
            } else {
                alert("ATeam3 saved successfully.");
            }
        });
    }
    function sendData5() {
        alert("Hey");
        if (attempt1 >= 1) {
            var percent1 = (Math.round(((upper1)/(attempt1))*100)/100);
        } else {
            var percent1 = 0;
        }
        var defenses1 = ((FT1D1)+(ST1D1)+(FT1D2)+(ST1D2)+(FT1D3)+(ST1D3)+(FT1D4)+(ST1D4)+(FT1D5)+(ST1D5));
        var T1D1 = ((FT1D1)+(ST1D1));
        var T1D2 = ((FT1D2)+(ST1D2));
        var T1D3 = ((FT1D3)+(ST1D3));
        var T1D4 = ((FT1D4)+(ST1D4));
        var T1D5 = ((FT1D5)+(ST1D5));
        var rootRef = new Firebase('https://frc-data.firebaseio.com/Team');
    	var usersRef = rootRef.child(T1Number+"/"+roundNumber);
    	usersRef.set({
    		AutoLower: autoLow1,
    		AutoUpper: autoUpper1,
    		AutoReached: autoDR1,
    		AutoCrossed: autoDC1,
    		Upper: upper1,
    		Attempt: attempt1,
    		PercentMade: percent1,
    		Lower: low1,
    		StealsBlocks: stealBlock1,
    		Defenses: defenses1,
    		Defense1: T1D1,
    		Defense2: T1D2,
    		Defense3: T1D3,
    		Defense4: T1D4,
    		Defense5: T1D5,
    		Challenged: TT1C,
    		Scaled: TT1S,
    		AllianceScore: allianceScore,
    	    AllianceFouls: fouls,
    		YellowCards: yellow1,
    		RedCards: red1,
    		TechFouls: tech1,
    		RP: ARP,
    		EStopDisabled: T1ESD,
        }
        alert("It worked");
        ,function(error) {
            if (error) {
                alert("Team1 could not be saved." + error);
            } else {
                alert("Team1 saved successfully.");
            }
        });
    }
    function sendData6() {
        alert("Hey");
        if (attempt2 >= 1) {
            var percent2 = (Math.round(((upper2)/(attempt2))*100)/100);
        } else {
            var percent2 = 0;
        }
        var defenses2 = ((FT2D1)+(ST2D1)+(FT2D2)+(ST2D2)+(FT2D3)+(ST2D3)+(FT2D4)+(ST2D4)+(FT2D5)+(ST2D5));
        var T2D1 = ((FT2D1)+(ST2D1));
        var T2D2 = ((FT2D2)+(ST2D2));
        var T2D3 = ((FT2D3)+(ST2D3));
        var T2D4 = ((FT2D4)+(ST2D4));
        var T2D5 = ((FT2D5)+(ST2D5));
        var rootRef = new Firebase('https://frc-data.firebaseio.com/Team');
    	var usersRef = rootRef.child(T2Number+"/"+roundNumber);
    	usersRef.set({
    		AutoLower: autoLow2,
    		AutoUpper: autoUpper2,
    		AutoReached: autoDR2,
    		AutoCrossed: autoDC2,
    		Upper: upper2,
    		Attempt: attempt2,
    		PercentMade: percent2,
    		Lower: low2,
    		StealsBlocks: stealBlock2,
    		Defenses: defenses2,
    		Defense1: T2D1,
    		Defense2: T2D2,
    		Defense3: T2D3,
    		Defense4: T2D4,
    		Defense5: T2D5,
    		Challenged: TT2C,
    		Scaled: TT2S,
    		AllianceScore: allianceScore,
    	    AllianceFouls: fouls,
    		YellowCards: yellow2,
    		RedCards: red2,
    		TechFouls: tech2,
    		RP: ARP,
    		EStopDisabled: T2ESD,
        }
        ,function(error) {
            if (error) {
                alert("Team2 could not be saved." + error);
            } else {
                alert("Team2 saved successfully.");
            }
        });
    }
    function sendData7() {
        alert("Hey");
        if (attempt3 >= 1) {
            var percent3 = (Math.round(((upper3)/(attempt3))*100)/100);
        } else {
            var percent3 = 0;
        }
        var defenses3 = ((FT3D1)+(ST3D1)+(FT3D2)+(ST3D2)+(FT3D3)+(ST3D3)+(FT3D4)+(ST3D4)+(FT3D5)+(ST3D5));
        var T3D1 = ((FT3D1)+(ST3D1));
        var T3D2 = ((FT3D2)+(ST3D2));
        var T3D3 = ((FT3D3)+(ST3D3));
        var T3D4 = ((FT3D4)+(ST3D4));
        var T3D5 = ((FT3D5)+(ST3D5));
        var rootRef = new Firebase('https://frc-data.firebaseio.com/Team');
    	var usersRef = rootRef.child(T3Number+"/"+roundNumber);
    	usersRef.set({
    		AutoLower: autoLow3,
    		AutoUpper: autoUpper3,
    		AutoReached: autoDR3,
    		AutoCrossed: autoDC3,
    		Upper: upper3,
    		Attempt: attempt3,
    		PercentMade: percent3,
    		Lower: low3,
    		StealsBlocks: stealBlock3,
    		Defenses: defenses3,
    		Defense1: T3D1,
    		Defense2: T3D2,
    		Defense3: T3D3,
    		Defense4: T3D4,
    		Defense5: T3D5,
    		Challenged: TT3C,
    		Scaled: TT3S,
    		AllianceScore: allianceScore,
    	    AllianceFouls: fouls,
    		YellowCards: yellow3,
    		RedCards: red3,
    		TechFouls: tech3,
    		RP: ARP,
    		EStopDisabled: T3ESD,
        }
        ,function(error) {
            if (error) {
                alert("Team3 could not be saved." + error);
            } else {
                alert("Team3 saved successfully.");
            }
        });
    }
</script>
&#13;
&#13;
&#13;

完整代码为here。编辑#1:抱歉,忘了粘贴代码。刚刚修好了。

1 个答案:

答案 0 :(得分:1)

一方面,你有一个语法错误:

}
alert("It worked");
,

您无法在向函数传递参数的过程中添加警报。