title: Onchange Error: undefined (setting 'value')
body: <p>I am asking for help, I have a problem because I get this error &quot;Uncaught TypeError: Cannot set properties of undefined (setting 'value')&quot; on my console. I can't use document.getElementByID because my ID will change, it must be class. Could someone help me what needs to be changed in this code?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function information(ele){
   
  for(var i=0; i&lt;30; i++){
   var address1 = document.getElementsByClassName('test2')[i];
  
    if( ele.value == "test4"){
      address1.value = "test5";
    } else if (ele.value == "test6"){
      address1.value = "test7";
    } else if (ele.value == "test8"){
      address1.value = "test9";
    }
  }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="form grup information"&gt;
    &lt;lable for="dates-full.names"&gt; Names full&lt;/lable&gt;
    &lt;input name="dates-full.names" list="dates-full.names" type="text"
      class="form grup test1" onchange="information(this)"&gt;
    &lt;datalist type="text" id="dates-full.names"&gt;
      &lt;option value="test4"&gt;
      &lt;option value="test6"&gt;
      &lt;option value="test8"&gt;
    &lt;/datalist&gt;
  &lt;/div&gt;
  
  
  &lt;div class="form grup test2"&gt;
    &lt;lable for="power-full.adress"&gt; Adress full&lt;/lable&gt;
    &lt;input id="test2" name="dates-full.adress" list="dates-full.adress" type="text"
    class="form grup test2"&gt;
    &lt;datalist type="text" id="dates-full.adress"&gt;
      &lt;option value="test5"&gt;
      &lt;option value="test7"&gt;
      &lt;option value="test9"&gt;
    &lt;/datalist&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>