1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Simple Javascript Question

Discussion in 'JavaScript' started by Silver89, Feb 21, 2008.

  1. #1
    Hi,

    Basically what happens at the moment is when a user wants to log into the chat room they have to input their username into a form input box and click the sign in (as below)

    		
    <input type="text" name="username" id="username" />
    <a href="#" onClick="login();">Enter the chat room &raquo;</a>
    Code (markup):
    However i want them to be signed in on body load with the username being $username, i'm not too knowledgable with javascript so i'm a tad lost.

    Thanks in advance for your help
     
    Silver89, Feb 21, 2008 IP
  2. greboguru

    greboguru Member

    Messages:
    78
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Hi

    I'm not to sure what your asking .. do you want the field to be pre-populated with the value of $username?
     
    greboguru, Feb 21, 2008 IP
  3. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #3
    Ok,

    At the moment users have to enter what they want as a username and click the link to sign in,

    what i want is

    that users are automatically signed in as the page loads with the username thats set in php, $username
     
    Silver89, Feb 21, 2008 IP
  4. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #4
    Ok, I'm lost but assuming the username is set before the page in question is loaded. When that page loads move the login() to the body onload function. body onload="login()" , which means the JS has to be in the head of the page. And you have to set the username using PHP to write out a form field for it.
     
    shallowink, Feb 21, 2008 IP