Hi,
having a bit of trouble with a simple ajax form. It all works fine except that if you press enter rather than the submit button it does not work. I've tried adding onsubmit to the form but that doesn't have an effect. Probably something really simple that i am missing so would appreciate any advice/help. read quite a few forum answers but hasn't helped me that much as i don't understand much javascript and can't really see what is wrong.

here is the code i have -

Code:
<html>
<head>

 <script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var name = document.getElementById('name').value;
	var type = document.getElementById('type').value;
	var queryString = "?name=" + name + "&type=" + type;
	ajaxRequest.open("GET", "feed.php" + queryString, true);
	ajaxRequest.send(null); 
}

//-->
</script>

</head>
<body>
<div align="center"> <font face="Arial, Helvetica, sans-serif">
 
  </font>
  <table width="780" border="0" align="center" cellpadding="6" cellspacing="6" bgcolor="#339933">
    <tr> 
      <td colspan="2">
      
      <div id='ajaxDiv'><font face="Arial, Helvetica, sans-serif">
        <form name='myForm' onsubmit='ajaxFunction()'>
          <p><font face="Arial, Helvetica, sans-serif"><strong>Enter full or part 
            of fish name: </strong> 
            <input name="name" type='text' id='name' size="44"/>
            </font></p>
          <p><font face="Arial, Helvetica, sans-serif"><strong>Select name type</strong> 
            <select name="type" id="type" size="1">
              <option value="com">common</option>
              <option value="sci">scientific</option>
            </select>
            </font></p>
          <p><font face="Arial, Helvetica, sans-serif"><br />
            <input type='button' value='search'>
            </font></p>
        </form>
        Your result 
          will display here</font></div></td>
    </tr>
  </table>
</div>
</body>
</html>
thanks