Jump to content

text box


westminster86

Recommended Posts

Im reading in data from a php file, the data is coming from a mysql database. The data is being displayed as follows in between the div tags,

 

carname1

carname2

carname3

 

How would i display the data in a text box without page refresh?

 

<html>
<head>
  <title>Catalog Search</title>

  <script language = "javascript">
    var XMLHttpRequestObject = false; 

    if (window.XMLHttpRequest) {
        XMLHttpRequestObject = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
      }

    function getData(dataSource, divID) 
    { 
      if(XMLHttpRequestObject) {
          var obj = document.getElementById(divID); 
          XMLHttpRequestObject.open("GET", dataSource, true); 

          XMLHttpRequestObject.onreadystatechange = function() 
          { 
            if (XMLHttpRequestObject.readyState == 4 && 
              XMLHttpRequestObject.status == 200) { 
                obj.innerHTML = XMLHttpRequestObject.responseText; 
            } 
          } 

          XMLHttpRequestObject.send(null); 
        }
      }

  </script>
</head>

<body>

  <form action="searchresults.php" method="post">
    Choose Search Type:<br />
    <select name="searchtype">
      <option value="manufacturer">Manufacturer</option>
      <option value="model">Model</option>
    </select>
    <br/><br/>
    Enter Search Term:<br />
    <input type="text" name="searchterm">
    <br/><br/>
    <input type="submit" value="Search">
    <input type ="button" value="Manufacturers" onclick="getData('give.php', 'targetDiv')">
  </form>

  <div id="targetDiv">




  </div> 

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.