If i were you I would use jQuery..
HTML FILE :
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" />
<script>
$(document).ready(function(){
$("button").click(function(){
var yr = document.getElementById('entry').value;
if (yr.length==0) {
document.getElementById("result1").innerHTML="";
document.getElementById("result2").innerHTML="";
return;
}
$.get("db.php?q="+yr,function(data,status){
if(status=="success")
{
var content = data;
document.getElementById("result").innerHTML = content;
}
else
{
}
});
});
});
</script>
</head>
<body>
<form>
Enter year: <input type="text" id="entry" />
<input type="button" value="check here" onclick="fetchData()" />
</form>
<div id="result">RESULTS</div>
</body>
</html>
db.php FILE:
<?php
$entry=$_GET["entry"];
$result = "";
$result = '<div id="result1">RESULT FOR RESULT1</div>';
$result .= '<div id="result2">RESULT FOR RESULT1</div>';
echo $result;
?>
If u still have any doubt do ask>>