title: Can I place text into 2 boxes rather than 1 using AJAX
body: <p>I have made a simple html page which fetches info from one of my databases' tables and pastes it into a text box. It does this by connecting to a PHP via an AJAX function which handles the request.</p>
  
  <p>What I am wondering is whether this data could be placed into two text boxes, rather than just the one. I don't know how to go about doing this, because in my code I have to state a single text box, would I have to make separate functions for each text box to get it to work or is there a simpler solution?</p>
  
  <p>HTML PAGE:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  function getDetails(str)
  {
  if (str=="")
    {
    document.getElementById("Text1").value=""; 
    return;
    } 
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
      document.getElementById("Text1").value=xmlhttp.responseText; // here is why it only      goes into "Text1"
      }
    }
  xmlhttp.open("GET","getDetails.php?q="+str,true);
  xmlhttp.send();
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form&gt;
  &lt;!--here a user enters an "RFID" and the details are returned into "Text1"--&gt;
  &lt;input type="text" name="RFID1" value="" onKeyup="getDetails(this.value)" /&gt; 
  &lt;input type="text" id="Text1" name="Text1" /&gt;
  &lt;input type="text" id="TextScore1" name="TextScore1"/&gt;
  &lt;/form&gt;
  
  &lt;br/&gt;
  
  &lt;form&gt;
  &lt;!--here a user enters another "RFID" and the details are also returned into "Text1"
  (though I would like it to go to Text2 and TextScore2)--&gt;
  &lt;input type="text" name="RFID2" value="" onKeyup="getDetails(this.value)" /&gt;
  &lt;input type="text" id="Text2" name="Text2"/&gt;
  &lt;input type="text" id="TextScore2" name="TextScore2"/&gt;
  &lt;/form&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP PAGE:</p>
  
  <pre><code>&lt;?php
  $q=$_GET["q"];
  
  $con = mssql_connect("SQL", "0001", "Password");
  if (!$con)
    {
    die('Could not connect: ' . mssql_get_last_message());
    }
  
  mssql_select_db("database1", $con);
  
  
  
  $sql="SELECT * FROM Scrabble WHERE RFID = '".$q."'";
  
  $result = mssql_query($sql);
  
  
  while($row = mssql_fetch_array($result))
    {
  
    echo $row['Tile'];
  
    echo $row['TileScore'];
    }
  
  
  mssql_close($con);
  ?&gt;
  </code></pre>
  
  <p>*note - My server uses MsSQL</p>
  
  <p>Another question, as you can see in the HTML file, I have two forms, I need the same function to happen to both forms. Here I figure I'm probably going to have to create another PHP file to connect to for each form. But just to be sure I'm going to ask, is it possible to keep it in a single file and if so how you would go about it?</p>
  
  <p><strong>EDIT</strong> it seems I have confused some people, I don't want the text to be put into both text boxes, but actually split the results into the two text boxes. Such that "Text" would end up in the text box Text1 and TextScore would end up in the text box TextScore1</p>