473,499 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7208
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1445
by: Jack | last post by:
Hi, I have a asp page where a checkbox, when clicked will disable all text boxes associated with the page. The following is a part of a code for the checkbox with its name and readonly...
3
1652
by: Jack | last post by:
Hi, I am trying to use the following code to make the save button invisible in the asp form when the checkbox is either on or the session variable has a particular value. THE CODE IS AS FOLLOWS:...
3
25300
by: Matt | last post by:
I want to know if readOnly attribute doesn't work for drop down list? If I try disabled attribute, it works fine for drop down list. When I try text box, it works fine for both disabled and...
2
4420
by: upersson | last post by:
Hi! When accessing my web page I build up the javascript and html dynamically. Depending on an parameter I want to set all the fields (input tags) readonly. How do I do this? Of course I can...
2
2908
by: Alan | last post by:
Hi all, I have one class including one collection. I use propertygrid to display and edit its properties. I'm trying to use reflection to change the status of one element to be readonly, for...
2
1856
by: Learning SQL Server | last post by:
Forgive the repost, but this is really troublesome and I hope SOMEONE can shed some light on it. I am trying to update a datarow via in-place editing from a dataset stored in session. When I...
7
5477
by: Jimbo | last post by:
Hi, I am trying to set the readonly attribute of a text input tag dynamically from javascript. The input element already exists in the form and I want to make it readonly when a particular...
3
1844
by: Hamed | last post by:
Hello I have a DataGrid object in my ASP.NET page that has the following template column. When I put the "readonly" attribute in the INPUT tag, it generates readonly="". <asp:TemplateColumn...
0
850
by: Bogdan | last post by:
Hi, I have a table adapter whose main query returns columns from multiple tables. The query calls a stored procedure which uses JOINs (or correlated subqueries - I get the same results in both...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.