arrays - Having issues with Javascript dice game -


I am trying to set a button to fire the two functions. This is a basic dice-based game: The top players work fine, but computer costs do not get any value.

  function welcome () {warning (" welcome "+ document.getElementById (" Fname "). Value +"! "); } Function Older (Age) {If (age and lieutenant; 18) {Warning ("Leave it down now"); }} // Player Dice Roll // Function Rolls () {var die1 = document.getElementById ("die1"); Var die2 = document.getElementById ("die2"); Var position = document.getElementById ("status"); // Random number (whole number) between 1 and 6 // var d1 = Math.floor (Math.Randem) * 6) + 1; Var d2 = Math.floor (Math.Random) * 6) + 1; Var Distall = D1 + D2; // Random number value // die1.innerHTML = d1; Die2.innerHTML = D2; Status.innerHTML = "You Rold" + Dice Total + "."; If (D1 == D2) {status.inner HTML + "Doubles! Roll Again"; }} // computer die roll // function compDice () {var die3 = document.getElementById ("die3") var die4 = document.getElementById ("die4") var status 2 = document.getElementById ("status2") var d3 = Math.floor (math.rendum) * 6) +1; Var d4 = Math.floor (Math.Rendum) * 6) +1; Var Dyetol = D3 + D4; Die3.innerHTML = D3; Die4.innerHTML = D4; Status2.innerHTML = "Computer Rolled" + Dice Total + "."; }  
  & lt; Form action = "#" method = "get" & gt; & Lt; P & gt; Player name: & lt; Input id = "fname" name = "fname" type = "text" size = "20" maxlength = "20" onblur = "welcome ()" /> & Lt; / P & gt; Age: & lt; Input id = "age" name = "age" id = "age" type = "text" size = "3" maximum length = "3" onBlur = "old too (this.value)" /> & Lt; / P & gt; & Lt; Div id = "die1" square = "dice" & gt; 0 & lt; / Div & gt; & Lt; Div id = "die2" square = "dice" & gt; 0 & lt; / Div & gt; & Lt; Button onclick = "rollDice ()"; "CompDice ()" & gt; Roll Dice & lt; / Button & gt; & Lt; H2 id = "status" style = "clear: left;" & Gt; & Lt; / H2 & gt; & Lt; Div id = "die3" square = "die" & gt; 0 & lt; / Div & gt; & Lt; Div id = "die4" square = "die" & gt; 0 & lt; / Div & gt; & Lt; H2 id = "status2" style = "clear: true;" & Gt;  gt; 

Change this:

  & lt; Button onclick = "rollDice ()"; "CompDice ()" & gt; Roll dice & lt; / Button & gt;  

For:

  & lt; Button onclick = "rollDice (); compDice ()" & gt; Roll dice & lt; / Button & gt;  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -