title: how to pass string variable of JavaScript to html form input,
body: <p>Like if I have element of array <code>name[1]='ahmad'</code> and I want it to be posted in html form.</p>
  
  <p>I used </p>
  
  <pre><code>document.getElementById('n').value=name[1];
  </code></pre>
  
  <p>but it's not posting. </p>
  
  <p>Form has: </p>
  
  <pre><code>&lt;input type="text" id="n" readonly="true"&gt;
  </code></pre>
  
  <p>i want to fill array by user and show these values in input readonly boxes on web page.
  full code is:</p>
  
  <pre><code>&lt;!dochtml html&gt;
  &lt;title&gt;Arrays of Js&lt;/title&gt;&lt;!--different methods of using declaring arrays--&gt;
  &lt;head&gt;
  &lt;h3&gt;Arrays usage by AFRN&lt;/h3&gt;
      &lt;script&gt;
      alert('hey');
      var names=[];
      //var n = prompt('enter name');
          for(var i=0; i&lt;=4; i++){
              names[i]=prompt('enter name: ');
          }
      /*var ids=['r1','r2','r3','r4','r5']
          for(var i=0; i&lt;=4; i++){
              document.getElementById(ids).value=name[i];
          }*/
      document.getElementById("r1").value=names[0];
      document.getElementById("r2").value=names[1];
      document.getElementById("r3").value=names[2];
      document.getElementById("r4").value=names[3];
      document.getElementById("r5").value=names[4];
      &lt;/script&gt;
          &lt;noscript&gt;JS not supported&lt;/noscript&gt;
  &lt;/head&gt;
  &lt;body bgcolor="yellow"&gt;
      &lt;form name="arryForm"&gt;
          &lt;input type="text" id='r1' name="a1" readonly="true"&gt; 
          &lt;input type="text" id='r2' name="a2" readonly="true"&gt; 
          &lt;input type="text" id='r3' name="a3" readonly="true"&gt; 
          &lt;input type="text" id='r4' name="a4" readonly="true"&gt; 
          &lt;input type="text" id='r5' name="a5" readonly="true"&gt; 
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>