469,936 Members | 2,420 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,936 developers. It's quick & easy.

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

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;
}
}
Jul 20 '05 #1
2 7053
"Fred K." <fr*******@yahoo.com> 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"]
Jul 20 '05 #2
DU
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

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Learning SQL Server | last post: by
7 posts views Thread by Jimbo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.