Hello,

I'm trying to learn ajax and i made a small application which search a database

the problem i'm facing that the user have to click the button (search). if he click enter (keybored) nothing will happend.

how could i make it working both ways, when he click the button or pressing enter in the keybored. ( If i can make it using one way is fine. but how do i disable pressing enter in the keybored )

HTML code

Code:
<form action="#" method="get" class="cmxform">
		<fieldset>
			<legend>Search Database</legend>	
				<ol>
					<li>
						<label for="q">Serial Number</label>
						<input type="text" name="q" id="q" />
					</li>
					<li> 
						<input type="button" name="search" onclick="getResponse(form.q.value)" value="Look up!" class="search" />
    				        </li>
				</ol>
		</fieldset>
	</form>
javascript code

Code:
function CreateRequestObject()
{
	var req;
	if( window.XMLHttpRequest )
	{
		//Mozilla, Safari, Netscape
		req = new XMLHttpRequest();
	}
	else if( window.ActiveXObject )
	{
		//Internet Explorer
		req = new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	return req;
}
// making the object
var http = CreateRequestObject();

function getResponse(q)
{
	http.open( "GET" , "result.php?q="+q );
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function handleResponse()
{
	if( http.readyState == 4 && http.status == 200 )
	{
		document.getElementById("result").innerHTML = http.responseText;
	}
}
php code

PHP Code:
<?php

    
if( $_GET['q'] == "123" )
    {
        echo 
"correct";
    }
    else
    {
        echo 
"mmm";
    }

?>
thank you