我有一个搜索框在页面的顶部。使用Ajax我想要一个div下拉页面以显示搜索结果。关键是我希望搜索结果覆盖下面的页面,而不是推下去。出于这个原因,我不能只在搜索框下面有一个div。我需要做一些更复杂的事情 - 但我不确定是什么。javascript/php div下拉搜索结果
以下代码在搜索框下面填充div。任何人都可以建议一种经济的方式来让div浏览页面,而不是把所有东西都推下来。感谢您的任何建议!
的JavaScript
function showResults(str) {
document.getElementById("results").innerHTML=xmlhttp.responseText;
document.getElementById("results").style.border="1px solid #A5ACB2";
//some ajax
xmlhttp.open("GET","search.php?str="+str,true);
xmlhttp.send();
}
HTML
<html>
<body>
<table><tr><td><img src="logo.gif"></td><td>
<input type="text" id="string" onkeyup="showResults(this.value)">
<div id="results"></div><td></tr>
<tr><td colspan=2
Main body of page. All sorts of text and html go here that I do not want pushed down.
</td></tr></table>
</body>
</html>
绝对可以。 – j08691
绝对定位div吗? – user1260310