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

Is there any way to make a SELECT field in HTML as a read only field?

P: n/a
Hi, all

Is there any way to make a SELECT field in HTML as a read only field?

Jack
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Ivo
"datactrl" aka Jack asks
Is there any way to make a SELECT field in HTML as a read only field?


It is read-only by design, as far as i am aware. Perhaps you mean making it
impossible to alter the selected option(s). Then

<select onfocus="this.nextSibling.focus()">

works fine (if the next sibling is another form element).

<select onfocus="window.focus()">

makes the list flash open for a moment.
You realize that javascript will not available on many machines.
HTH
Ivo
Jul 23 '05 #2

P: n/a
Hi, Ivo
Thanks a lot. Yes, I mean making it impossible to alter the selected option.
I try the way you advised. It works the most times but sometimes the drop
list stays there insteead of flashing a moment. Do you have the same
problem? I use IE6.

Jack

"Ivo" <no@thank.you> wrote in message
news:40**********************@news.wanadoo.nl...
It is read-only by design, as far as i am aware. Perhaps you mean making it impossible to alter the selected option(s). Then

<select onfocus="this.nextSibling.focus()">

works fine (if the next sibling is another form element).

<select onfocus="window.focus()">

makes the list flash open for a moment.
You realize that javascript will not available on many machines.
HTH
Ivo

Jul 23 '05 #3

P: n/a
Yeah I noticed.
Ok try:
<select onChange="this.selectedIndex=0">
You can change the zero (which means the very first option) with a number
representing the index of the option that you want to keep selected EVEN if
the user attempts to select another one.
ps note that selectedIndex is CASE SENSITIVE: the i must be uppercase

ciao
Alberto
http://www.unitedscripters.com/

"datactrl" <qu***@tpg.com.au> ha scritto nel messaggio
news:40******@dnews.tpgi.com.au...
Hi, Ivo
Thanks a lot. Yes, I mean making it impossible to alter the selected option. I try the way you advised. It works the most times but sometimes the drop
list stays there insteead of flashing a moment. Do you have the same
problem? I use IE6.

Jack

Jul 23 '05 #4

P: n/a
It works on when the original Selected Value is fixed. But my problem is the
selected value comes from a database on server. Just can't change back to
the original unless the original has been saved.

Jack
"Alberto" <NO****@hotmail.com> wrote in message
news:c8**********@lacerta.tiscalinet.it...
Yeah I noticed.
Ok try:
<select onChange="this.selectedIndex=0">
You can change the zero (which means the very first option) with a number
representing the index of the option that you want to keep selected EVEN if the user attempts to select another one.
ps note that selectedIndex is CASE SENSITIVE: the i must be uppercase

ciao
Alberto
http://www.unitedscripters.com/

"datactrl" <qu***@tpg.com.au> ha scritto nel messaggio
news:40******@dnews.tpgi.com.au...
Hi, Ivo
Thanks a lot. Yes, I mean making it impossible to alter the selected

option.
I try the way you advised. It works the most times but sometimes the drop list stays there insteead of flashing a moment. Do you have the same
problem? I use IE6.

Jack


Jul 23 '05 #5

P: n/a
Arrange a default selected index. A select menu should have a defualt
selected index.
ciao
Alberto

"datactrl" <qu***@tpg.com.au> ha scritto nel messaggio
news:40********@dnews.tpgi.com.au...
It works on when the original Selected Value is fixed. But my problem is the selected value comes from a database on server. Just can't change back to
the original unless the original has been saved.

Jack
"Alberto" <NO****@hotmail.com> wrote in message
news:c8**********@lacerta.tiscalinet.it...
Yeah I noticed.
Ok try:
<select onChange="this.selectedIndex=0">
You can change the zero (which means the very first option) with a number
representing the index of the option that you want to keep selected EVEN

if
the user attempts to select another one.
ps note that selectedIndex is CASE SENSITIVE: the i must be uppercase

ciao
Alberto
http://www.unitedscripters.com/

"datactrl" <qu***@tpg.com.au> ha scritto nel messaggio
news:40******@dnews.tpgi.com.au...
Hi, Ivo
Thanks a lot. Yes, I mean making it impossible to alter the selected

option.
I try the way you advised. It works the most times but sometimes the

drop list stays there insteead of flashing a moment. Do you have the same
problem? I use IE6.

Jack



Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.