I'm not overly familiar with javascript, so I have used it sparingly on my site. Here's what I'm trying to do. I am using the JPilot chat program to connect to irc through my site. Its written in javascript but it does allow for customization of the chat login page. It gives me the option of setting the chat user's nickname on chat login using:
<param name="NickName" value="Guest">
however I want to automatically insert my member's username (its stored in a cookie on login) instead of Guest.
<param name="NickName" value="<? $username ?>">
I already have retrieved the username from the cookie and put it in the variable $username. Could someone tell me how I should go about doing this?
wherever you need the variable in your javascript. Remember that because JS is a client side scripting language you can have your PHP print out any javascript you need.
I do this same thing on my site for my search feature.
And depending on where you want the variable at you can just pring it out like that.
var username = "<? print($username); ?>";
its really simple when you think about it but if you try to make it too complicated (oh no trying to make 2 scripting languages talk to each other) it can get confusing.
Bookmarks