js下拉菜单源代码,js下拉菜单和js下拉菜单源代码以及js横向下拉菜单还有js 二级下拉菜单 等功能的原理都是差不多的。
想要做XMLHTTP+JavaScript的多级联动菜单,onChange出现问题
<Script language="javascript">
function GetResult(id,str)
{
var oBao = new ActiveXObject("Microsoft.XMLHTTP");
oBao.open("POST","Menu_Server.asp?ID="+escape(id),false);
oBao.send();
if (str == 省份){省份.outerHTML = '<Select name="省份">'+ unescape(oBao.responseText) +'</Select>';}
if (str == 城市){城市.outerHTML = '<Select name="城市">'+ unescape(oBao.responseText) +'</Select>';}
if (str == 区域){区域.outerHTML = '<Select name="区域">'+ unescape(oBao.responseText) +'</Select>';}
//if (str == 省份)document.getElementById("省份").outerHTML="<select name="省份">"+oBao.responseText+"</select>";
//if (str == 城市)document.getElementById("城市").outerHTML="<select name="城市">"+oBao.responseText+"</select>";
//if (str == 区域)document.getElementById("区域").outerHTML="<select name="区域">"+oBao.responseText+"</select>";
}
</Script>
<body onload="javascript:GetResult(15,省份)">
<Select name="省份" onChange="javascript:GetResult(this.options[this.options.selectedIndex].value),城市)"></Select>
<Select name="城市" onChange="javascript:GetResult(this.options[this.options.selectedIndex].value),区域)"></Select>
<Select name="区域"></Select>
oBao.responseText的值为
<option style='BACKGROUND-COLOR: #eeeeee; COLOR: #ff0000'>==请选择==</option><option value='16'>直辖市</option><option value='21'>安徽</option><option value='22'>河北</option><option value='23'>河南</option><option value='24'>湖北</option><option value='25'>山东</option><option value='26'>广东</option><option value='27'>广西</option><option value='28'>福建</option><option value='29'>江苏</option><option value='30'>浙江</option><option value='31'>湖南</option><option value='32'>江西</option><option value='33'>吉林</option><option value='34'>黑龙江</option><option value='35'>辽宁</option><option value='36'>陕西</option><option value='37'>云南</option><option value='38'>贵州</option><option value='39'>四川</option><option value='40'>青海</option><option value='41'>甘肃</option><option value='42'>宁夏</option><option value='43'>内蒙古</option><option value='44'>山西</option><option value='45'>海南</option><option value='46'>新疆</option><option value='47'>西藏</option><option value='48'>香港</option><option value='49'>澳门</option><option value='50'>台湾</option>