the 7th Hokage Posted August 26, 2009 Share Posted August 26, 2009 i have a function that works... well kind of. 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 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.