benjaminmorgan Posted July 3, 2012 Report Share Posted July 3, 2012 (edited) My site is at http://blackjack.web44.net/blackjack and I am trying to make it where the numbers add together correctly but I can't get the numbers to add when I click the hit button it doesn't add the 3,4, or 5 number to the current score which is assigned in the variable yosco in deal function. I am trying to make it where it adds number 3 in the 1st hit function and if they hit again it adds all of the numbers plus number 4 then the same with 5. Edited July 4, 2012 by benjaminmorgan Link to comment Share on other sites More sharing options...
benjaminmorgan Posted July 4, 2012 Author Report Share Posted July 4, 2012 Edited to update problem. Link to comment Share on other sites More sharing options...
falkencreative Posted July 4, 2012 Report Share Posted July 4, 2012 Personally, I would approach dealing with this by adding console.log() statements that track when functions are being called and what the values of the various variables you are using are. I would start by checking to make sure functions are being called when you expect them to, and that the variables you are using hold the values that you expect them to. In all of your hit() functions, I'm not seeing any code that actually updates the number that displays on the screen. I'm seeing a "yosco" variable that gets added to, but I'm not seeing that variable used to update the "Your cards equal: X" text. Link to comment Share on other sites More sharing options...
benjaminmorgan Posted July 4, 2012 Author Report Share Posted July 4, 2012 (edited) When I add this it doesn't work still. It should update it with the new yosco variable after the hit button is correct. The function is being called because the card is dislaying. yosco = num1 + num2 + number3; yougot.innerHTML = "Your cards equal: " + yosco; Well now it appears to be working, guess I had to clear my cache. Thanks Ben. Happy Independence Day. Edited July 4, 2012 by benjaminmorgan Link to comment Share on other sites More sharing options...
falkencreative Posted July 4, 2012 Report Share Posted July 4, 2012 Good, glad to hear you got it working. Link to comment Share on other sites More sharing options...
benjaminmorgan Posted July 4, 2012 Author Report Share Posted July 4, 2012 (edited) Grr, Another problem. Now I can't hide the hit button when someone busts. If they keep hitting hit it makes them lose 10 points until the button is unclickable. I have tried to hide the hit buttons in the code but none seem to work. Apart from that the adding and busting is working right. Also if you click the deal button after you bust and there is still a hit button showing 2 of them will show up after you click deal. The 2 buttons call a different function. Edited July 4, 2012 by benjaminmorgan Link to comment Share on other sites More sharing options...
benjaminmorgan Posted July 4, 2012 Author Report Share Posted July 4, 2012 (edited) firefox doesn't seem to work at all. Grr. It seems to work in every other browser! Well not the hiding part but the changing cards and hit buttons. Firefox doesn't add the card either. Edited July 4, 2012 by benjaminmorgan Link to comment Share on other sites More sharing options...
falkencreative Posted July 4, 2012 Report Share Posted July 4, 2012 To get it to work in Firefox, you need to clean up the errors: -- use of undeclared variable num3 -- use of undeclared variable num4 -- yougot not defined (it's only defined within deal() but due to variable scope, it isn't accessible within the hit() functions) You need to watch the Javascript console for errors, and deal with anything that pops up. Link to comment Share on other sites More sharing options...
benjaminmorgan Posted July 5, 2012 Author Report Share Posted July 5, 2012 I don't see anything in the javascript console. I fixed the 3 errors you posted. The hit button still shows up. Link to comment Share on other sites More sharing options...
Recommended Posts