By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
"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

P: n/a
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.