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> Link to comment https://forums.phpfreaks.com/topic/96018-text-box/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.