[SOLVED] Calling a Javascript function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RayonMazter
Forum Newbie
Posts: 6
Joined: Wed Feb 02, 2005 6:12 pm

[SOLVED] Calling a Javascript function

Post by RayonMazter »

Ive seen this question asked tons of times, but for something different.

This cant be done through an event.

i want to execute a java script function when server sends certain info.

But i cant just do the
echo <script>;
echo TheFunction();
echo </script>;

because it keeps adding to their html uhh is it called cache? lol

view source and it shows up, i need a way to just call it through php.

ex of what i mean:


function msgbox(msg)
{
alert (msg);
}


server sends "message: blah"

case = "message":
(this is where i need to call function without using echo/print)



any hints??


thanks
Last edited by RayonMazter on Wed Feb 02, 2005 9:34 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

not possible, that I know of.

You'll need to engineer a Javascript function to periodicly look at the body text for these messages...

what's the purpose of this?
RayonMazter
Forum Newbie
Posts: 6
Joined: Wed Feb 02, 2005 6:12 pm

Post by RayonMazter »

making a webversion of a game i made,

purpose is that server sends player list,
then sends a certain string whenever a new player logs in, or someone logs out (which requires the function).


but u just gave me the best idea, thanks.

i'll have php do this

data comes, then it does

echo 'var NewPlayer=' . $data . ";";


then i can just have the function (like u said ) call every few seconds to update the new info,


never would have thought. Thanks again

Rayon
Post Reply