SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    bracken
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Another ques of javascript!!

    I wanna try make a chatterbox where u enter ure name and ure message and press enter and it comoes up in the textbox!!!
    Do i use the var blahblah= "BLAH";
    document.WriteIn
    please help me!!
    I really wanna know how!!

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    once the page has been rendered (loaded), document.write will rewrite the page, resulting in a blank page with the text you just wrote. Not quite what you're looking for.

    What you'll need to do is get the text box you want to write to, then set it's text attribute equal to the text attribute in the box you typed in. You can do all this in a method that is called when a button has been clicked by setting onclick='yourFunctioName();' within the button tag.

    your function might have code that looks something like this:

    var source = document.getElementById( "sourceBox" );
    var target = document.getElementById( "targetBox" );
    target.text = source.text;

  3. #3
    SitePoint Member
    Join Date
    Sep 2004
    Location
    bracken
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks!!can i use a regular text box??

  4. #4
    SitePoint Member
    Join Date
    Sep 2004
    Location
    bracken
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but wat about the name of the textbox???Dont i need to type it somwwhere so it goes into the textbox, the writing that is!!!

  5. #5
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    yup, regular text boxes.

    ie:
    HTML Code:
    <input type='text' id='target' />


Bookmarks

Posting Permissions

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