title: (index):40 Uncaught TypeError: Cannot set property 'innerHTML' of null at getanswer ((index):40) at HTMLButtonElement.onclick ((index):204)
body: <p>Whenever I click the submit button it should validate the answer with the desired value given in the database. How can I solve this error?</p>
  <p>The button performs a form submission which contains the table and rows. I have included a piece of code of that.</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  
  
  &lt;button type=&quot;submit&quot; id=&quot;btn1&quot; onclick=&quot;getanswer();&quot;&gt; submitanswer &lt;/button&gt;
  
  &lt;tr&gt;
    &lt;td&gt;{{Result.id}} ) {{Result.questions}}&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;input type=&quot;radio&quot; id=&quot;choice1&quot; name=&quot;{{Result.id}}&quot; class=&quot;ans&quot; value=&quot;{{Result.choice1}}&quot;&gt;{{Result.choice1}}&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function() {
    $(&quot;#btn1&quot;).click(function() {
      $(&quot;.btn1&quot;).show();
      $(&quot;.btn1&quot;).attr(&quot;disabled&quot;, true);
    });
  });
  
  function getanswer() {
    document.getElementById(&quot;useranswer&quot;).innerHTML = &quot;&quot;;
    var e = document.getElementsByTagName('input');
    for (i = 0; i &lt;= e.length; i++) {
      if (e[i].type == 'radio') {
        if (e[i].checked) {
          document.getElementById(&quot;useranswer&quot;).innerHTML += &quot;Q&quot; + e[i].name + &quot;Answer you selected is :&quot; + e[i].value + &quot;&lt;br/&gt;&quot;;
        }
      }
    }
  }
  </code></pre>