e editable select no button code example

Example 1: e editable select no button

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>

<link href="https://rawgit.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.css" rel="stylesheet">
<script src="https://rawgit.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.js"></script>

<form action="http://stackoverflow.com/questions/38437449/edit-jquery-editable-select/" method="get">
    <select id="basic" name="basic">
        <option value="0">Zero</option>
        <option value="1">One</option>
        <option value="2">Two</option>
    </select>
    <input type="submit" value="Submit" />
</form>

Example 2: e editable select no button

$(function () {
  var selectedEleValue = null;
  $('#basic').editableSelect({
    onSelect: function (element) {
      selectedEleValue = element.val();
      console.log('The val is: ' + element.val() + ' The text is: ' + element.text());
    }
  });
  $('form[action="http://stackoverflow.com/questions/38437449/edit-jquery-editable-select/"]').on('submit', function(e) {
    if (selectedEleValue != null) {
      $('#basic').val(selectedEleValue);
    }
  })
});

Tags:

Misc Example