2016-03-19 11 views
0

FRCチームのプログラムをコーディングしていて、ボタンに問題がありました。 OnClickは、SendData7()を介して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'); 
 
    \t var usersRef = rootRef.child(roundNumber+"/"+allianceColor+"/"+T1Number); 
 
    \t usersRef.set({ 
 
    \t \t AutoLower: autoLow1, 
 
    \t \t AutoUpper: autoUpper1, 
 
    \t \t AutoReached: autoDR1, 
 
    \t \t AutoCrossed: autoDC1, 
 
    \t \t Upper: upper1, 
 
    \t \t Attempt: attempt1, 
 
    \t \t PercentMade: percent1, 
 
    \t \t Lower: low1, 
 
    \t \t StealsBlocks: stealBlock1, 
 
    \t \t Defenses: defenses1, 
 
    \t \t Challenged: TT1C, 
 
    \t \t Scaled: TT1S, 
 
    \t \t YellowCards: yellow1, 
 
    \t \t RedCards: red1, 
 
    \t \t TechFouls: tech1, 
 
    \t \t 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'); 
 
    \t var usersRef = rootRef.child(roundNumber+"/"+allianceColor+"/"+T2Number); 
 
    \t usersRef.set({ 
 
    \t \t AutoLower: autoLow2, 
 
    \t \t AutoUpper: autoUpper2, 
 
    \t \t AutoReached: autoDR2, 
 
    \t \t AutoCrossed: autoDC2, 
 
    \t \t Upper: upper2, 
 
    \t \t Attempt: attempt2, 
 
    \t \t PercentMade: percent2, 
 
    \t \t Lower: low2, 
 
    \t \t StealsBlocks: stealBlock2, 
 
    \t \t Defenses: defenses2, 
 
    \t \t Challenged: TT2C, 
 
    \t \t Scaled: TT2S, 
 
    \t \t YellowCards: yellow2, 
 
    \t \t RedCards: red2, 
 
    \t \t TechFouls: tech2, 
 
    \t \t 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'); 
 
    \t var usersRef = rootRef.child(roundNumber+"/"+allianceColor+"/"+T3Number); 
 
    \t usersRef.set({ 
 
    \t \t AutoLower: autoLow3, 
 
    \t \t AutoUpper: autoUpper3, 
 
    \t \t AutoReached: autoDR3, 
 
    \t \t AutoCrossed: autoDC3, 
 
    \t \t Upper: upper3, 
 
    \t \t Attempt: attempt3, 
 
    \t \t PercentMade: percent3, 
 
    \t \t Lower: low3, 
 
    \t \t StealsBlocks: stealBlock3, 
 
    \t \t Defenses: defenses3, 
 
    \t \t Challenged: TT3C, 
 
    \t \t Scaled: TT3S, 
 
    \t \t YellowCards: yellow3, 
 
    \t \t RedCards: red3, 
 
    \t \t TechFouls: tech3, 
 
    \t \t 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'); 
 
    \t var usersRef = rootRef.child(T1Number+"/"+roundNumber); 
 
    \t usersRef.set({ 
 
    \t \t AutoLower: autoLow1, 
 
    \t \t AutoUpper: autoUpper1, 
 
    \t \t AutoReached: autoDR1, 
 
    \t \t AutoCrossed: autoDC1, 
 
    \t \t Upper: upper1, 
 
    \t \t Attempt: attempt1, 
 
    \t \t PercentMade: percent1, 
 
    \t \t Lower: low1, 
 
    \t \t StealsBlocks: stealBlock1, 
 
    \t \t Defenses: defenses1, 
 
    \t \t Defense1: T1D1, 
 
    \t \t Defense2: T1D2, 
 
    \t \t Defense3: T1D3, 
 
    \t \t Defense4: T1D4, 
 
    \t \t Defense5: T1D5, 
 
    \t \t Challenged: TT1C, 
 
    \t \t Scaled: TT1S, 
 
    \t \t AllianceScore: allianceScore, 
 
    \t  AllianceFouls: fouls, 
 
    \t \t YellowCards: yellow1, 
 
    \t \t RedCards: red1, 
 
    \t \t TechFouls: tech1, 
 
    \t \t RP: ARP, 
 
    \t \t 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'); 
 
    \t var usersRef = rootRef.child(T2Number+"/"+roundNumber); 
 
    \t usersRef.set({ 
 
    \t \t AutoLower: autoLow2, 
 
    \t \t AutoUpper: autoUpper2, 
 
    \t \t AutoReached: autoDR2, 
 
    \t \t AutoCrossed: autoDC2, 
 
    \t \t Upper: upper2, 
 
    \t \t Attempt: attempt2, 
 
    \t \t PercentMade: percent2, 
 
    \t \t Lower: low2, 
 
    \t \t StealsBlocks: stealBlock2, 
 
    \t \t Defenses: defenses2, 
 
    \t \t Defense1: T2D1, 
 
    \t \t Defense2: T2D2, 
 
    \t \t Defense3: T2D3, 
 
    \t \t Defense4: T2D4, 
 
    \t \t Defense5: T2D5, 
 
    \t \t Challenged: TT2C, 
 
    \t \t Scaled: TT2S, 
 
    \t \t AllianceScore: allianceScore, 
 
    \t  AllianceFouls: fouls, 
 
    \t \t YellowCards: yellow2, 
 
    \t \t RedCards: red2, 
 
    \t \t TechFouls: tech2, 
 
    \t \t RP: ARP, 
 
    \t \t 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'); 
 
    \t var usersRef = rootRef.child(T3Number+"/"+roundNumber); 
 
    \t usersRef.set({ 
 
    \t \t AutoLower: autoLow3, 
 
    \t \t AutoUpper: autoUpper3, 
 
    \t \t AutoReached: autoDR3, 
 
    \t \t AutoCrossed: autoDC3, 
 
    \t \t Upper: upper3, 
 
    \t \t Attempt: attempt3, 
 
    \t \t PercentMade: percent3, 
 
    \t \t Lower: low3, 
 
    \t \t StealsBlocks: stealBlock3, 
 
    \t \t Defenses: defenses3, 
 
    \t \t Defense1: T3D1, 
 
    \t \t Defense2: T3D2, 
 
    \t \t Defense3: T3D3, 
 
    \t \t Defense4: T3D4, 
 
    \t \t Defense5: T3D5, 
 
    \t \t Challenged: TT3C, 
 
    \t \t Scaled: TT3S, 
 
    \t \t AllianceScore: allianceScore, 
 
    \t  AllianceFouls: fouls, 
 
    \t \t YellowCards: yellow3, 
 
    \t \t RedCards: red3, 
 
    \t \t TechFouls: tech3, 
 
    \t \t RP: ARP, 
 
    \t \t EStopDisabled: T3ESD, 
 
     } 
 
     ,function(error) { 
 
      if (error) { 
 
       alert("Team3 could not be saved." + error); 
 
      } else { 
 
       alert("Team3 saved successfully."); 
 
      } 
 
     }); 
 
    } 
 
</script>

完全なコードがhereです。編集#1:申し訳ありませんが、コードを貼り付けるのを忘れました。ちょうどそれを固定した。一つのことについてよく

答えて

1

、あなたは、構文エラーがあります。

} 
alert("It worked"); 
, 

あなたが関数に引数を渡すの途中でアラートを追加することはできません。

+0

ありがとう、それはエラーでした。それは再び動作します! –

関連する問題