Search code examples
javahtmlscriptlet

Disable dropdown list without any event


I have one jsp and want to disable dropdown list using scriplet without any onclick method or event in dropdown menu

         <%
                boolean something= true;
                if(something){
      // here I want to get plc1 using id and want to disable it if it is true
                }else{
//do some thing
}
            %>

my dropdown html code is here

<td bgcolor='' align="center" ><select id = "plc1" name="place1" onclick="this.parentNode.style.backgroundColor = this.value">
                     <option value='red'>Park here</option>
                     <option value='green'>Cancel</option>
                        </select></td>

how to do it? any hint please?


Solution

  • <%
            boolean something=false;
            String state = "";
            if(something){
                state = "disabled";
                // here I want to get plc1 using id and want to disable it if it is ture
            }else{
               state = "enable"; 
            }
            %>
    

    Html

    <select <%= state %> id = "plc1" >
    

    Now its working Thanks