按下回车键时如何获取内容?
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Mode) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 're.asp';
var pmeters = "lname=" + encodeURI( document.getElementById("txtCustomerID").value) +
"&tMode=" + Mode;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
document.getElementById("txtCustomerID").value = '';
}
}
}
</script>
<form name="frmMain"action="#">
<textarea name="txtCustomerID" id="txtCustomerID"onkeydown="if (event.keyCode == 13) { this.form.submit(); return false; }"></textarea>
**> how to get content when enter form keyboard (enter submit function)**
<input type="button" name="btnAdd" id="btnAdd" value="Add"OnClick="JavaScript:doCallAjax('ADD');">
<span id="mySpan"></span>
</form>