View Full Version : Subtracting won't work

12-25-2011, 10:21 AM
<script type="text/javascript">
var x=200;
function update()
function attack()
if (x<10)
document.write("You Won")
<body onload="update()">
<div id="health">
<input type="button" value="Attack" onclick="attack()" />

I don't see that x loses 10 what's the problem.:confused::confused:

12-25-2011, 10:42 AM
When you click on the Attack button, attack is called. x is subtracted by 10, but the innerHTML has not been updated, nor have you checked if x is less tan 10.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum