i have it set that it runs on click. it utilizes some ajax and javascript to print php to the page without refreshing.
the problem is when i click the button the same output shows up each time.
what i want is the number to decrease and the new value to be available
this is the actual code
CODE
function smack($target)
{
$dmg=$this->ATT-=$target->DEF;//amount of HP loss
$newHP=$target->HP-=$dmg;// HP after dmg
echo $target->HP." hit points remaining.";
$target->HP=$newHp;
}
this is what it outputs
This is only a test.100 .87 hit points remaining.
This is only a test.100 .87 hit points remaining.
This is only a test.100 .87 hit points remaining.
This is only a test.100 .87 hit points remaining.
This is only a test.100 .87 hit points remaining.
This is only a test.100 .87 hit points remaining.
This is only a test.100 .87 hit points remaining.
this is what i would like it to say
This is only a test.100 .87 hit points remaining.
This is only a test.100 .74 hit points remaining.
This is only a test.100 .61 hit points remaining.
... and so on
note that this is outputted to the page on button press. with ajax to write to the page without refreshing. I'm not sure if that's the cause of this or not. any help would be appreciated.
