Display the data in the text box but not allow the user to edit it?

They have: 105 posts

Joined: Mar 2006

Is it possible to diable a textbox so the user can't edit the value or copy it? I want to be able to display the data in the text box (from the database) but not allow the user to edit it. How can I do this? Confused

Busy's picture

He has: 6,151 posts

Joined: May 2001

place this in the tag

readonly="readonly"

like so:

<?php
echo stripslashes($description);
?>

They have: 105 posts

Joined: Mar 2006

Thanks, can the stripslashes be used in asp? I have fields the user enters data into and sometimes if they put too many //// it gives an SQL error, how can I make these inputboxs SQL injection proof etc? is the stripslashes a way of doing this?

Is there a way to do this without javascript? like using a label?

Busy's picture

He has: 6,151 posts

Joined: May 2001

Sorry I do not know asp

stripslashes is from the database, addslashes would be to enter into database, but thats php

a label just labels the field, readonly isn't javascript, other option is just plain ole text

He has: 698 posts

Joined: Jul 2005

You could also use:

... disabled="disabled" ...
'

instead of the readonly option, although I've never understood the difference.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.