This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Question on making a dropdown list read-only Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Question on making a dropdown list read-only" Watch "Question on making a dropdown list read-only" New topic
Author

Question on making a dropdown list read-only

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

Is there not a way to set a DROPDOWN list to READONLY using jQuery or straight javascript? The objective is to NOT let a user change the value selected in the dropdown list.

I am able to set a dropdown list to DISABLE using jQuery but I cannot seem to make it readonly. Please see the code line in RED below.

I'm sure I'm doing something wrong I just don't know what it is. Any help/direction would be appreciated. Thanks.

Here is the jQuery code:

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

No, you cannot change a select list so that the value cannot be changed. What you could do is bind to the change event, and when it is changed, change it back to whatever you want. You could possibly get extra fancy and position a transparent div over the top of it (would have to use an iframe hack for IE) but that seems like a lot of work for little gain.

Final advice is if you have a select list that shouldn't be changed, don't show a select list.


GenRocket - Experts at Building Test Data
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

Thanks for the quick reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on making a dropdown list read-only