Set the selected item from the drop-down list to a text box

advertisements

How can I make my drop down list shows the value in my text box? The value is always one the items of drop down list, but how can I set the selected item of drop down list equals to the value of my textbox, after click?

 $('<input  name="Product Name" data-type="string" \>')
     .appendTo(container)
     .kendoDropDownList({
         dataSource: mydata,
         dataTextField: "Text",
  });


As far as I could understand what you're trying to accomplish, you can do it like this

var selectList = document.getElementById('selectList');
selectList.addEventListener('change', function() {
    var selectedVal = selectList.value;
    var inputText = document.getElementById('textInput');
  inputText.value = selectedVal;
});

See it in action -> Fiddle