Read only TextArea

Discussion in 'HTML & Website Design' started by kie, Nov 28, 2007.

  1. #1
    Frens,I would like to know how to make a textarea which the text is only read only and also I want below the text area there is a button that when pressed will highlight the text which is in the text area, thanks in advance :)
     
    kie, Nov 28, 2007 IP
  2. calebbender

    calebbender Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can disable and enable it

    You do this by setting the disabled property and then onclick of the button do something like document.getElementByID("buttonname").disabled = false
     
    calebbender, Nov 28, 2007 IP
  3. kie

    kie Peon

    Messages:
    330
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks calebbender, but I'm a bit newbie :p so if you are not mind can frens directly write the html code? :)
     
    kie, Nov 28, 2007 IP
  4. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #4
    kie, to disable a text area you need to set the disabled attribute to disabled thus it will be like this: <textarea disabled="disabled"></textarea>

    For the select all button, I think this could help you http://dynamicdrive.com/dynamicindex11/selectform.htm



    Don
     
    Dondon2d, Nov 28, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    As Dondon2d said, just add disabled as an attribute of the textarea element. You only need to use disabled="disabled' when using XHTML.

    
    [b]HTML VERSION[/b]
    <textarea disabled></textarea>
    
    [b]XHTML VERSION[/b]
    <textarea disabled="disabled"></textarea>
    
    Code (markup):
     
    Dan Schulz, Nov 28, 2007 IP
  6. flakdesign

    flakdesign Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes you can add a disabled="disabled" for the text area

    In the case of an input, if you want to disable it you can use
    <input type="text" disabled></input>
     
    flakdesign, Nov 29, 2007 IP
  7. kie

    kie Peon

    Messages:
    330
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks frens :) I have tried what you all said but the result is I can't highlight the text also :p what I mean is read only but still people can highlight the text :) oya dondon2d I have seen the site you gave me..but that one when I have clicked on the select all..it will first highlight the text but when I move my mouse it will make the highlight text becomes not high lighted again(using Firefox browser)..waiting for your help frens :)
     
    kie, Nov 29, 2007 IP
  8. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ah. In that case you want to use readonly="readonly" (or just readonly if using an HTML DOCTYPE).
     
    Dan Schulz, Nov 29, 2007 IP
  9. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #9
    For selecting the text, I believe all modern browsers support the "select" method for form inputs.

    For instance the following works in every browser I have access too.
    <textarea readonly="readonly" onclick="this.select()">I'll never change !</textarea>
    Code (markup):
     
    joebert, Nov 29, 2007 IP
  10. kie

    kie Peon

    Messages:
    330
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks Dan and Joe, it works now, God Bless :)
     
    kie, Nov 29, 2007 IP