title: Why can't javascript set the value of a HTML form element?
body: <p>Title says it all, i am setting a value in a variable in a javascript.
  I want to set that value as value of the one of the row in my form.</p>
  
  <p>here is the code, this is based on previous similar questions and their accepted answers, but somehow it does not work for me.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
      var counter = 0;
      var limit = 50;
  
      function addInput(divName){
           if (counter == limit)  {
                alert("You have reached the limit of adding " + counter + " inputs");
           }
           else {
                var newdiv = document.createElement('div');
                newdiv.innerHTML = "Element " + (counter + 1) + " &lt;input type='text' name='myInputs[]'&gt;";
                document.getElementById(divName).appendChild(newdiv);
                counter++;
           }
      }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form method="POST"  align="center"&gt;
          &lt;script&gt;
          var emotion = "";
          var raw = Math.random();
          var final = Math.ceil(raw * 4);
          if (final == 1)
              document.getElementById("someid").value = "A";
          else if (final == 2)
              document.getElementById("someid").value = "B";
          else if (final == 3)
              document.getElementById("someid").value = "C";
          else if (final == 4)
              document.getElementById("someid").value = "D";
          &lt;/script&gt;
       &lt;div id="dynamicInput"&gt;
          Title&lt;br&gt;&lt;input type="text" value="" name="myInputs[]" id="someid" disabled&gt;
       &lt;/div&gt;
       &lt;input type="button" value="Add another event" onClick="addInput('dynamicInput');"&gt;
       &lt;br&gt;
       &lt;input type="submit" value="Submit"&gt;
  
  &lt;/form&gt;
  
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I also tried something like: </p>
  
  <pre><code>document.forms[0].myInputs[0].value="Whatever"
  </code></pre>
  
  <p>inside the script tags, but that also does not work.</p>
  
  <p><strong>Edit_1</strong>
  I expect some value in the disabled input field, just below the title, but its empty.</p>
  
  <p>Here is the image:</p>
  
  <p><a href="https://i.stack.imgur.com/9ksdL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ksdL.png" alt="enter image description here"></a></p>
  
  <p>How can I have some value based on a random number generator there? </p>