471,073 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

readOnly attribute doesn't work for drop down list?

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 readOnly attribute.

For example, #1 will work, but #2 doesn't work

1) <SELECT name="streetDirection" class="FormInput" DISABLED>
In JavaScript, I have InputForm.streetDirection.disabled = false;

2) <SELECT name="streetDirection" class="FormInput" readOnly>
In JavaScript, I have InputForm.streetDirection.readOnly= false;

any ideas? thanks!!
Jul 23 '05 #1
3 25173
Matt wrote:
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 readOnly attribute.

For example, #1 will work, but #2 doesn't work

1) <SELECT name="streetDirection" class="FormInput" DISABLED>
In JavaScript, I have InputForm.streetDirection.disabled = false;

2) <SELECT name="streetDirection" class="FormInput" readOnly>
In JavaScript, I have InputForm.streetDirection.readOnly= false;

any ideas? thanks!!

"Select" is always read only.
Mick
Jul 23 '05 #2


Matt wrote:
I want to know if readOnly attribute doesn't work for drop down list?
2) <SELECT name="streetDirection" class="FormInput" readOnly>
In JavaScript, I have InputForm.streetDirection.readOnly= false;


According to
http://www.w3.org/TR/html4/interact/forms.html#h-17.6
there is no readonly attribute defined for <select> elements thus there
can't be a property for HTMLSelectElement objects:
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-94282980

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #3
Matt wrote:
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 readOnly attribute.

For example, #1 will work, but #2 doesn't work

1) <SELECT name="streetDirection" class="FormInput" DISABLED>
In JavaScript, I have InputForm.streetDirection.disabled = false;

2) <SELECT name="streetDirection" class="FormInput" readOnly>
In JavaScript, I have InputForm.streetDirection.readOnly= false;

any ideas? thanks!!


The readonly attribute appears to not be supported on <select> elements
by Firefox 0.9, IE6SP1 or Opera 7.51.

<url:
http://msdn.microsoft.com/workshop/a...cts/select.asp
/> confirms this by not listing "readonly/readOnly" as a valid property
on the <select> object.

<url: http://www.w3.org/TR/html401/interac...html#h-17.12.2 /> also
seems to confirm this behavior: "The following elements support the
readonly attribute: INPUT and TEXTAREA."

That spec doesn't specifically exclude SELECT, but it doesn't include it
either, and the fact that none of the 3 user agents I tested support
readonly on <select> points to user agents adhering to the letter of the
spec.

In other words, what you are seeing is documented behavior.

Besides, what would be the point of a readonly <select>? It would appear
to be a normal <select>, but it wouldn't open as a normal <select> does,
which would be very confusing for the user.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Darshak Shah | last post: by
2 posts views Thread by Yoshitha | last post: by
7 posts views Thread by Jimbo | last post: by
8 posts views Thread by Ed Dror | last post: by
6 posts views Thread by Johnny Jörgensen | last post: by

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.