View Full Version : locking textareas

04-02-2010, 04:28 PM
Hi All,

I am currently developing a website with a built in CMS where users can log in and view content uploaded by administrators. I have created the HTML table to display the form however, I am echoing data from my database into the textarea allowing users to view this content. I have also incorporated a text editor which allows administrators to change the layout, size, font and colour of documents uploaded to the website.

I have attempted to use <textarea readonly="readonly"><?php echo $row['words'];?></textarea>


<textarea disabled="true"><?php echo $row['words'];?></textarea>

and seem to be having no luck. I would prefer to use the readonly option as the disabled approach enforces a gray style view on the font.

Any help would be greatly appreciated.



04-02-2010, 04:59 PM
What happens with the readonly attribute? It should make it read only.


04-02-2010, 05:07 PM
When I apply the read only attirbute the textarea remains open to modification. Could the text editor have something to do with this? As when I remove the javascript the read only attirbute will work however it does not display the database contents in the correct formatt.

04-02-2010, 05:14 PM
it would be far less effort to do something like

if user is admin {
// show text box with contents
} else {
// just show the text in a formatted div, if desired.

any javascript hack can just be disabled.

04-02-2010, 05:31 PM
Ok thanks I will give that a try