是否有可能有2个输入字段从XML中搜索列表,但它们也可以相互依赖于结果......
例如, 输入品牌 - 亨氏
然后 输入项目 - 番茄
我如何调整我的表单/ JS来这样做?
function showResult(str,IdtoEdit,item) {
if (str.length==0) {
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
document.getElementById("livesearch").style.border="1px solid #A5ACB2";
}
}
xmlhttp.open("GET","<?php echo SITE_URL; ?>test.php?q="+str+"&item="+item+"&id="+IdtoEdit,true);
xmlhttp.send();
}
brand <input type="text" id="brandsearch" value="" onkeyup="showResult(this.value,currCount,document.getElementById('itemsearch').value); showsearch('livesearch');" autocomplete="off" onKeyPress="return disableEnterKey(event)" />
-
item <input type="text" value="" id="itemsearch" onkeyup="showResult(getElementById('brandsearch').value,currCount,this.value); showsearch('livesearch');" autocomplete="off" onKeyPress="return disableEnterKey(event)" >