permaculture playing cards*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 386

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: 15299
    
    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: 386

Thanks for the quick reply.
 
Consider Paul's rocket mass heater.
 
subject: Question on making a dropdown list read-only
 
Similar Threads
Question on jQuery ajax functionality & troubleshooting called bean in JSF page
Question on .submit and reloading form values AFTER the submit button is clicked
trying to populate hidden field on my JSF form using jQuery
Newbie question using jquery validator plugin on my JSF page
Question on using jQuery's .attr AFTER form is submitted