Skip to content Skip to sidebar Skip to footer

Struts 2 Select Readonly Property

I have a situation where I need to make drop down value to read only. But since the only has disabled property, how to make behav

Solution 1:

It looks like putting a HTML attribute contenteditable="true" makes it to behave like readonly. That a way you couldn't select the value from dropdown.


Solution 2:

You can do it Write some CSS, and then just put a HTML attribute readonly="true"

 /*Select2 ReadOnly Start*/
    select[readonly].select2-hidden-accessible + .select2-container {
        pointer-events: none;
        touch-action: none;
    }
    
    select[readonly].select2-hidden-accessible + .select2-container .select2-selection {
        background: #eee;
        box-shadow: none;
    }
    
    select[readonly].select2-hidden-accessible + .select2-container .select2-selection__arrow, select[readonly].select2-hidden-accessible + .select2-container .select2-selection__clear {
        display: none;
    }
    
    /*Select2 ReadOnly End*/

Post a Comment for "Struts 2 Select Readonly Property"