title: Javascript GetElementById Set Value To Input
body: <p>I am trying to set value to my input but I want to do this while my data ends. As you know id must be unique in html. So i created an 'element' variable and I am increasing it.
  I want to make my input text my model's CustomerName.</p>
  
  <p>That's my code.</p>
  
  <pre><code>var element = 0;
  var HTML = "";
  while (element !== 5) {
      HTML += "&lt;input id=senderName" + element + " class=senderNameText type=text&gt;";
      document.getElementById("senderName" + element).value = "@Html.DisplayFor(model =&gt; model.CustomerName)";
      element++;
  }
  
              div.innerHTML = HTML;
              document.body.appendChild(div);
  </code></pre>
  
  <p>When I check it at console in Chrome it is written as "Cannot set property 'value' of null".</p>
  
  <p>What should I do.</p>
  
  <p>Thanks.</p>