HighDots Forums  

Need to set Non-Editable input field AFTER it's generated

alt.html.tags alt.html.tags


Discuss Need to set Non-Editable input field AFTER it's generated in the alt.html.tags forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ElephantWalker
 
Posts: n/a

Default Need to set Non-Editable input field AFTER it's generated - 04-28-2004 , 04:22 AM






Hi all,

I don't have the control of an input text html tag, it's generated as
follow :
<INPUT type="text" maxlength='40' name="BI" value="60"
class="InputText" size="35">

But I need to be abble to make it non-editable using javascript later
in the code, when page is loaded.

I tryed to do it using the disable property, but this is not what I
need, because the value of the field can be dynamically changed using
javascript, and this cannot be done if field is disabled.

So I really need it to be non-editable : the user can select what's in
the input text field but cannot modify it.

if I had the control of the input text generation, I would have done
like this
<INPUT type="text" maxlength='40' name="BI" value="60"
class="InputText" size="35" onFocus=this.blur()>

but I can't...

anybody can help ?

Thanx.

Tom.

Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Need to set Non-Editable input field AFTER it's generated - 04-28-2004 , 07:39 AM






elephantwalker (AT) free (DOT) fr (ElephantWalker) wrote:

Quote:
I don't have the control of an input text html tag, it's generated as
follow :
INPUT type="text" maxlength='40' name="BI" value="60"
class="InputText" size="35"
I wonder what you mean by lack of control. Anyway, the element lacks the
id="..." attribute, which is important to accessibility (for use with a
<label> element) as well as to modern scripting methods (I'm thinking of
the getElementById() method), and the attributes look odd - what input
might be typically 40 characters long, yet have the two-character string
"60" as a meaningful initial value?

Quote:
But I need to be abble to make it non-editable using javascript later
in the code, when page is loaded.
I think the URL would be needed now. What's the big picture? What would
you like to happen when JavaScript is disabled?

Quote:
I tryed to do it using the disable property,
There is no such property. There is the disabled attribute/property, but
it should normally be avoided since when scripting is off, it will remain
disabled, no matter what.

Quote:
but this is not what I
need, because the value of the field can be dynamically changed using
javascript, and this cannot be done if field is disabled.
It sounds like you want to use the readonly attribute/property. Whether
this is what you _need_ is a quite different issue. Besides, disabled
fields _can_ be changed via scripting, when scripting is enabled - but
they do not contribute to the form data set when the form is submitted
(this is part of the _meaning_ of the disabled attribute).

Quote:
So I really need it to be non-editable : the user can select what's in
the input text field but cannot modify it.
Then you need something impossible. The user can use a browser that does
not support the attributes that would prevent editing, or he could create
his own copy of the form, edit it, and then paly with it.

If you just wish to let the user select something, why don't you present
it as normal text, outside form fields?

Quote:
if I had the control of the input text generation, I would have done
like this
INPUT type="text" maxlength='40' name="BI" value="60"
class="InputText" size="35" onFocus=this.blur()

but I can't...
Well, that's good, since you would have broken navigation by tabbing,
which is essential to everyone who cannot use (or does not wish to use) a
mouse or some other pointing device.

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




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.