Toby A Inkster said:
That is one possibility, but it begs the question of whether
<input> is really an appropriate element to use in the first place.
Indeed. And I wouldn't advice anyone to give advice on such things
unless the advisor _knows_ the difference beteen disabled and readonly
and doesn't need to ask others to "try" it.
If Matt doesn't want the end user to be able to input a new value,
why use <input> at all. Why not (for example) use:
<span style="border: 1px solid black; padding:2px">Joe</span>
That would show (when CSS is enabled) the word "Joe" in a box, which
would make it look a bit like an input field. I don't think that would
be adequate in most cases, since it would suggest that the user _can_
change it and it would mean that the string "Joe" is not passed to the
form handler (which might not be needed actually, but I doubt that).
***
The question was multiposted, so apparently the OP is not interested in
getting quickly the best possible answer. For others, here's a copy of
my response in alt.html.tags:
How to make a html control (text box, checkbox, etc...) be read only?
Using the attribute readonly (or if you play the XHTML game,
readonly="readonly") in an <input> element. But by the specification,
it applies to elements with type="text" and type="password" only
(though browsers might be more liberal).
For example, in the following text box code, value "Joe" is in text
box, but user still able to edit it. I don't want user able to edit
it.
<input type="TEXT" name="username" value="Joe">
So why do you have the field there in the first place?
It's safer to use
<input type="hidden" name="username" value="Joe">
Username: Joe
partly because not quite all browsers support the readonly attribute,
partly because this makes it much clearer that the user is not expected
to change the username.