<body onLoad = "initAjax()">
<script LANGUAGE = "JavaScript">
var xmlHttp;
function initAjax(){
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}else if(window.ActiveXObject){
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
window.alter("该浏览器不支持Ajax");
}
}
}
}
function query(){
var select = document.queryForm.select.value;
var keyword = document.queryForm.keyword.value;
var url = "querySer?select = " + select + "&keyword = " + keyword;
xmlHttp.open("post",url,true);
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState == 4){
ResuleSet.innerHTML = xmlHttp.responseText;
}
}
xmlHttp.send();
}
</script>
<h1>Welcome to CD_Selling Online System of Music Company</h1><hr>
<form name = "queryForm">
<select name = "select">
<option value = "By CD_Name">By CD_Name</option>
<option value = "By Singer">By Singer</option>
<option value = "By Song">By Song</option>
</select>
<input type = "text" name = "keyword">
<input type = "button" value = "query" onClick = "query()">
</form>
<div id = "ResuleSet"></div>
</body>
为什么不能把select和keyword的值传给servlet呢(能够进入servlet)
------最佳解决方案--------------------------------------------------------
传递前前台能取到select 和keyword的值吗?
------其他解决方案--------------------------------------------------------
window.alter(select);
-->window.alert(select);
------其他解决方案--------------------------------------------------------
我用window.alter(select);页面没反应,应该是不能得到
------其他解决方案--------------------------------------------------------
所以还是老实用document.getElementById()
吧
------其他解决方案--------------------------------------------------------
用docement.```.```.value不好呢?
------其他解决方案--------------------------------------------------------