How do I include make an html textarea dynamic?

Discussion in 'HTML & Website Design' started by Imozeb, Mar 4, 2010.

  1. #1
    How do I include make an html textarea dynamic? For example I want javascript to print text into the textarea. I've been trying this but it isn't working. Is this the write way or is there a better way to do this?

    Html code:
    <textarea name="chatoutput" cols="30" rows="20" disabled readonly="readonly"><div id="div_chattext"></div></textarea>
    Code (markup):
    Please help.
     
    Imozeb, Mar 4, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    Why do you want to write <div id="div_chattext"></div> in the textarea? Maybe there is a better way to do what you want.
     
    s_ruben, Mar 5, 2010 IP
  3. amitash

    amitash Well-Known Member

    Messages:
    399
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    125
    #3
    What CMS do you want to use.. If it is PHP, then you can use php variable tags!
     
    amitash, Mar 5, 2010 IP
  4. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't know if there is a better way to do what I want but mabye you can suggest one. This is what I want to do.

    I want to get html code and simple text from a text file and output it into the textarea, so that the user can read the data from the text file and click the html links. The textarea's for format so the text doesn't just print straight down the screen. I've already tested all my code using div tags but now I want to output the data into the textarea. How do I do this. I've been trying something like this (I'll only show the relevent parts):

    Html Code:
    <textarea name="output" id="output" cols="30" rows="20" readonly="true" disabled></textarea>
    Code (markup):
    Javascript Code:
    document.getElementById('output').innerHTML = xmlhttpget.responseText;
    Code (markup):
    PHP Code:
    ECHO("$thedata");
    Code (markup):

    Thanks.

    ~imozeb
     
    Imozeb, Mar 5, 2010 IP
  5. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #5
    To put it briefly, you want to display html code in the textarea and you want textarea for editing the text, do you?
     
    s_ruben, Mar 5, 2010 IP
  6. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Right, that is what I want, the textarea is just for format. It is non editable, just an output box.
     
    Imozeb, Mar 6, 2010 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Then what are you using a textarea for? Sorry, but that sounds more like a DIV's job... Given your using AJAX to retriece the info and stuffing it in via innerHTML - again, it SOUNDS like a job for a DIV, not a textarea.
     
    deathshadow, Mar 6, 2010 IP
  8. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #8
    And you can make div editable if you want.
     
    s_ruben, Mar 6, 2010 IP
  9. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks everyone. I have done some more research and found a few commands to use with the div tag to do what I want.
     
    Imozeb, Mar 6, 2010 IP