Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i set the drop down as readonly in jquery? [duplicate]

I want to set the drop down as readonly. For that I user the code readonly="readonly".But its not working in asp.netmvc4.How can I solve this problem?Please help

like image 687
Nithin Viswanathan Avatar asked May 23 '13 12:05

Nithin Viswanathan


People also ask

How do you make a dropdown Uneditable?

You need to add a "disabled" property to the form dropdown class.

How do I make a dropdown list readonly?

Dropdown (select element) is always read only. User do not edit it. User can select any of the option of its own chice. Unlike other html elements, it dont have a attribute which can make the element readony and prevent users to change its value.

How do you prevent duplicate selection in dropdown?

You also can remove the duplicates from the table list firstly, then create the drop down list. Select the column range you want to use in the table, the press Ctrl + C to copy it, and place it to another position by pressing Ctrl + V. Then keep selecting the list, click Data > Remove Duplicates.

How do you make a field readonly in jQuery?

To make a textarea and input type read only, use the attr() method .


1 Answers

You can do like this

Make other options disabled except the current one.

$('option:not(:selected)').attr('disabled', true);

See Demo

like image 127
Dhaval Marthak Avatar answered Nov 14 '22 16:11

Dhaval Marthak