js onchange values code example

Example 1: onchange on select tag

<select id="comboA" onchange="getComboA(this)">
  <option value="">Select combo</option>
  <option value="Value1">Text1</option>
  <option value="Value2">Text2</option>
  <option value="Value3">Text3</option>
</select>

Example 2: js select on change value

document.getElementById('my-select').addEventListener('change', function() {
  console.log('You selected: ', this.value);
});

Example 3: javascript input onchange get value

var element = document.getElementById("myInput");
element.onchange = function() {
  console.log(element.value);
}

Example 4: javascript bind onchange event

transport_select.setAttribute("onchange", function(){toggleSelect(transport_select_id);});
// or
transport_select.onchange = function(){toggleSelect(transport_select_id);};

Tags:

Html Example