Jump to content

output trouble (buttons)


the 7th Hokage

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.