[jquery] How to make a dropdown readonly using jquery?

As @Kanishka said , if we disable a form element it will not be submitted . I have created a snippet for this problem . When the select element is disabled it creates a hidden input field and store the value . When it is enabled it delete the created hidden input fields .

More info

_x000D_
_x000D_
jQuery(document).ready(function($) {_x000D_
  var $dropDown = $('#my-select'),_x000D_
    name = $dropDown.prop('name'),_x000D_
    $form = $dropDown.parent('form');_x000D_
_x000D_
  $dropDown.data('original-name', name); //store the name in the data attribute _x000D_
_x000D_
  $('#toggle').on('click', function(event) {_x000D_
    if ($dropDown.is('.disabled')) {_x000D_
      //enable it _x000D_
      $form.find('input[type="hidden"][name=' + name + ']').remove(); // remove the hidden fields if any_x000D_
      $dropDown.removeClass('disabled') //remove disable class _x000D_
        .prop({_x000D_
          name: name,_x000D_
          disabled: false_x000D_
        }); //restore the name and enable _x000D_
    } else {_x000D_
      //disable it _x000D_
      var $hiddenInput = $('<input/>', {_x000D_
        type: 'hidden',_x000D_
        name: name,_x000D_
        value: $dropDown.val()_x000D_
      });_x000D_
      $form.append($hiddenInput); //append the hidden field with same name and value from the dropdown field _x000D_
      $dropDown.addClass('disabled') //disable class_x000D_
        .prop({_x000D_
          'name': name + "_1",_x000D_
          disabled: true_x000D_
        }); //change name and disbale _x000D_
    }_x000D_
  });_x000D_
});
_x000D_
/*Optional*/_x000D_
_x000D_
select.disabled {_x000D_
  color: graytext;_x000D_
}
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
_x000D_
<form action="#" name="my-form">_x000D_
  <select id="my-select" name="alpha">_x000D_
    <option value="A">A</option>_x000D_
    <option value="B">B</option>_x000D_
    <option value="C">C</option>_x000D_
  </select>_x000D_
</form>_x000D_
<br/>_x000D_
<button id="toggle">toggle enable/disable</button>
_x000D_
_x000D_
_x000D_