469,307 Members | 2,181 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

how can I make a dropdownlist control readonly using javascript?

Is there any way to set a DROPDOWN list to READONLY using jQuery or straight javascript? The objective is to NOT let a user change the previously selected value of dropdown list.
Jul 9 '14 #1
1 5649
8,651 Expert Mod 8TB
I can think of several ways:

you could disable/remove all options except for the selected one.

you could disable the dropdown itself (if you need the value anywhere else either save it in a variable (JS) or hidden field (form submit))

instead of disabling the dropdown you can replace it with a text/hidden input or read-only text field.

but generally, if you want a selection list to be un-selectable then donít use a selection list (either by omitting in the first place or by replacing it with a more suitable element)
Jul 9 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Steve | last post: by
1 post views Thread by shotokan99 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.