根据以前的下拉值填充第三个菜单
我有三个下拉菜单,前两个工作正常,第三个给我同样的头痛。 由于某种原因,一旦第二个下拉值改变,它就会丢失第一个菜单的值。 这是代码:
function getXMLHTTP() { //function to return the xml http object var xmlhttp=false; try{xmlhttp=new XMLHttpRequest(); } catch(e){try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; }}} return xmlhttp; } function getColor(CategoryId) { var strURL="getColor.php?Category="+CategoryId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('qcolor').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } }
直到这里所有似乎都工作其余的是错误但不确定是什么:
function getBrand(CategoryId,ColorId) { var strURL="getBrand.php?Category="+CategoryId+"&Color="+ColorId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('qbrand').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } }
HTML代码:
Interesting Posts