SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Outside Providence
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a text area on my page and would like to have it be read-only, not allowing the user to modidy the information, but allowing them to scroll through comments. Any suggestions about how this can be accomplished?

    Your help is greatly appreciated.

    April
    TEAMWORK is the fuel that allows common people
    to produce uncommon results.

  2. #2
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    April

    There are a couple of ways to accomplish this. First of all you can simply put a readonly attribute in the textarea tag. This will allow readers to see what you have, but won't allow them to edit your text.

    Code:
    <form name="myForm">
    <textarea name="myText" readonly>
    This is some text
    </textarea>
    The problem with this is that Netscape doesn't recognize the readonly attribute. So a work around for this is to blur() the textarea when ever someone clicks on it.

    Code:
    <form name="myForm">
    <textarea name="myText" onfocus="blur()">
    This is some text
    </textarea>
    It's the same with the disabled attribute as well. Disabled works very much like readonly, but doesn't allow the visitor to even select the text in the textarea. But again, Netscape doesn't recognize this attribute so you will need to use the example above to make your page cross-browser compatable.

    You could get really fancy and write a javascript saying that if the user is using the netscape browser to "blur()" the text area, but if they are using Microsoft IE to give it a "readonly" attribute.

    Hope this helps.

    Ruff!!
    Joe Eliason
    Just a dog learnin' PHP from cat.


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
  •