Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Readonly form text boxes

3 views
Skip to first unread message

Dave S

unread,
Sep 8, 2001, 1:42:23 PM9/8/01
to
Is it possible to dynamically make a form text box readonly in NN4+ ?

If so, how ?

Cheers
Dave


Jukka K. Korpela

unread,
Sep 10, 2001, 4:55:52 PM9/10/01
to
"Dave S" <dave_s...@hotmail.com> wrote:

> Is it possible to dynamically make a form text box readonly in NN4+ ?

You cannot do anything dynamic in HTML, to begin with.

And NN 4 doesn't support the READONLY attribute or corresponding
features in the "document object model", i.e. you can't set anything
equivalent in a scripting language either.

You could use JavaScript to modify things so that the box loses focus
when focused on, but this a) works only when JavaScript is enabled,
b) isn't really equivalent to READONLY. cf. to
http://www.cs.tut.fi/~jkorpela/forms/readonly.html

As usual in dead end situations, it is best to track back to the point
where you had a problem that you tried to solve in a particular way,
and try and find a different approach.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


Jim Ley

unread,
Sep 10, 2001, 6:39:31 PM9/10/01
to
On Mon, 10 Sep 2001 20:55:52 GMT, "Jukka K. Korpela"
<jkor...@cs.tut.fi> wrote:

>"Dave S" <dave_s...@hotmail.com> wrote:
>
>> Is it possible to dynamically make a form text box readonly in NN4+ ?
>
>You cannot do anything dynamic in HTML, to begin with.
>

>You could use JavaScript to modify things so that the box loses focus
>when focused on, but this a) works only when JavaScript is enabled,

And you can in most implementations still "paste" into the box, e.g.
on windows highlight any contents that are still there, "right click"
and select paste. - This is in addition to any javascript approach.

>b) isn't really equivalent to READONLY. cf. to
>http://www.cs.tut.fi/~jkorpela/forms/readonly.html

This from the above page is unsafe, and not per any standard DOM and
is definately unsupported in some

this.form.fld3.focus()

use
document.forms['formname'].elements['fld3].focus()
and only then you're making the assumption that focus, and form
elements are exposed, this is probably a pretty safe assumption inside
an onfocus event handler, but you may want to take precautions if you
like braces with your belt.

It also certainly doesn't work on "all JavaScript enabled browsers"
but as you're saying not 100% the rarities are probably ok to ignore.

>As usual in dead end situations, it is best to track back to the point
>where you had a problem that you tried to solve in a particular way,
>and try and find a different approach.

Naturally.

Jim.

0 new messages