SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2000
    0 Post(s)
    0 Thread(s)
    Hi everyone,

    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?


  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    East Lansing, MI USA
    0 Post(s)
    0 Thread(s)
    its very simple.

    All you need to do is

    <? print("$username"); ?>

    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.

    onLoad = "return findinpage('<? print("$term"); ?>');"

    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.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts