Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Q: how to set the readonly attribute to false (IE and Moz)

Reply
Thread Tools

Q: how to set the readonly attribute to false (IE and Moz)

 
 
Fred K.
Guest
Posts: n/a
 
      12-09-2003
Hi,

I have form text fields that have the attribute readonly. I wish to
use a javascript (invoked by a button on my page) to erase the values
and set
the readonly attribute to false. How do I do this?

Here's what I have that is not working with respect to setting
readonly to false:
function nsfields ( bDefaults ) {

if ( bDefaults == "Yes" ) {
// insert the default values in the fields
document.form1.ns1_hostname.value = 'foo.foobar.com';
document.form1.ns1_hostname.readonly = 'readonly';

} else {
// Blank the fields
document.form1.ns1_hostname.value = '';
document.form1.ns1_hostname.readonly = false;
}
}
 
Reply With Quote
 
 
 
 
Vjekoslav Begovic
Guest
Posts: n/a
 
      12-09-2003
"Fred K." <> wrote:

> Here's what I have that is not working with respect to setting
> readonly to false:


<snip>

> document.form1.ns1_hostname.readonly = false;


Use: document.form1.ns1_hostname.readOnly = false;
^
Note the case.

And, BTW, it is safer to write:

document.forms["form1"].elements["ns1_hostname"]


 
Reply With Quote
 
 
 
 
DU
Guest
Posts: n/a
 
      12-09-2003
Fred K. wrote:

> Hi,
>
> I have form text fields that have the attribute readonly. I wish to
> use a javascript (invoked by a button on my page) to erase the values
> and set
> the readonly attribute to false. How do I do this?
>
> Here's what I have that is not working with respect to setting
> readonly to false:
> function nsfields ( bDefaults ) {
>
> if ( bDefaults == "Yes" ) {
> // insert the default values in the fields
> document.form1.ns1_hostname.value = 'foo.foobar.com';
> document.form1.ns1_hostname.readonly = 'readonly';
>
> } else {
> // Blank the fields
> document.form1.ns1_hostname.value = '';
> document.form1.ns1_hostname.readonly = false;
> }
> }


http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-88461592
but
http://www.robinlionheart.com/stds/h...only_text_only

DU

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
when using the PassWord recvovery server control do we need to set the enablePasswordRetrieval attribute to false or True rote ASP .Net 0 09-30-2008 06:56 AM
False positive, false intrusion, false alarm Nick Computer Security 3 04-26-2006 07:40 PM
false instance and false class and set_trace_func trans. (T. Onoma) Ruby 0 09-25-2004 05:34 PM
ASP.NET Readonly panel function with readonly checkbox, readonly radiobutton Jonathan Hyatt ASP .Net Web Controls 1 06-08-2004 07:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57