0

I am developing an ASP.net MVC application and jQuery, I want to store all state values in selection element and display it as readonly because I will auto select the correct state when user enters zipcode.

When user clicks on the select element I am hiding the options in Chrome as well as Firefox by using following CSS rule.

select[readonly] option {
    display: none;
}

Rendering code:

@Html.DropDownListFor(m => m.AddressView.StateCode, Model.AddressView.StateNameList, "Select", new
                     {
                         @class = "form-control ddl-state disabled-dropdown",
                         id = "ddlEmployerState",
                         @disabled = "disabled",
                         @readonly = "readonly",
                     })

This did not work for IE, please suggest me options to fix this.

A CSS fix is much appreciated since the value of the element changes dynamically and I don't want to call jQuery methods to hide and show values on the fly.

RandomUser
  • 1,843
  • 8
  • 33
  • 65

1 Answers1

0

Try this

Remove the disabled and selected attribute using jquery like this

$("select option").prop("selected", false);
$("select").prop("disabled", false);
Santhosh Kumar
  • 1,672
  • 1
  • 16
  • 26