Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 1.07 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to migrate a .change function from jQuery to plain Javascript
  2. <select id="faq" class="onchance_fill">...</select>
  3.   <select id="pages" class="onchance_fill">...</select>
  4.   <select id="faq" class="onchance_fill">...</select>
  5.        
  6. <input type="text" onchange="selectByValue(this.form,'linklisthref',this.value);" value="" class="mceFocus" name="href" id="href" style="width: 260px;">
  7.        
  8. $('.ajax_onchance_fill').change(function() {
  9.         data = $('.ajax_onchance_fill').val();
  10.         $('#href').text(data);
  11.     });
  12.        
  13. <script type="text/javascript">
  14.   function load() {
  15.   var elements = document.getElementsByClassName('onchance_fill');
  16.   for(e in elements){
  17.       elements[e].onchange = function(){
  18.           document.getElementById('href').value = this.value;
  19.      }      
  20.   }
  21.   }
  22. </script>
  23.        
  24. document.getElementsByClassName("ajax_onchance_fill").onchange = function() {
  25.    getElementById('href').value = this.options[this.selectedIndex].text;
  26. };
  27.        
  28. $('.ajax_onchance_fill').change(function() {
  29.         var data = $(this).val();
  30.         $('#mytextboxid').val(data);
  31.     });