title: displaying the values in textbox based on AJAX fetched entries
body: <p>I've a table in which addition rows can be generatred as per the user need by clicking a javascript function.</p>
  
  <p>Each row has a drop down list, and based on the values of this an AJAX script fetchs some values which has to be displayed in corresponding textfields of the same row..</p>
  
  <p>here is the code for HTML..</p>
  
  <pre><code>&lt;td&gt;&lt;div align="center"&gt;
  
              &lt;label&gt;
              &lt;select name="gcno1" id="gcno1"  onchange="fetch_gc(this)"&gt;
               &lt;option value="0"&gt;NIL&lt;/option&gt;
               &lt;option value="2"&gt;1&lt;/option&gt;
              &lt;?php while($row=mysql_fetch_array($result))
                      {
              ?&gt;
                &lt;option value="&lt;?php echo $row[0]; ?&gt;"&gt;&lt;?php echo $row[0]; ?&gt;&lt;/option&gt;
                &lt;?php }?&gt;
              &lt;/select&gt;
              &lt;/label&gt;
            &lt;/div&gt;&lt;/td&gt;
            &lt;td&gt;&lt;div align="center"&gt;&lt;input name="date1" id="date1" type="text" size="10" /&gt;
            &lt;/div&gt;&lt;/td&gt;
  </code></pre>
  
  <p>and here is the AJAX which I'm writing...</p>
  
  <pre><code>    xmlhttp = new XMLHttpRequest();
      var value=encodeURIComponent(document.getElementById('gcno1').value);
      var parameters="param1="+value;
  
      xmlhttp.open("POST", 'fetch_gc.php', true);
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.send(parameters);
      xmlhttp.onreadystatechange=function(){
          if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) 
          {
              var detail=xmlhttp.responseText.split('+');
              alert(detail[0]);
              document.getElementsByName('date1').value=String(detail[0]);
              alert("life " + document.getElementById('gcno1').value);
  
          }
      }
  </code></pre>
  
  <p>The alert inside the AJAX shows the correct response text, detail[0] but is unable to put the value in corresponding textbox i.e. with name 'gcno1'......</p>
  
  <p>Please help me with this problem...</p>