westminster86 Posted March 13, 2008 Share Posted March 13, 2008 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.