2 回答
TA贡献1951条经验 获得超3个赞
<div>
<select id="sel1" onchange="selChange(this)">
<option value='1'>A</option>
<option value='2'>B</option>
<option value='3'>C</option>
<option value='4'>D</option>
<option value='5'>E</option>
</select>
</div>
<script type="text/javascript" >
function selChange(obj)
{
var oi = obj.options[obj.selectedIndex].value;
var ot = obj.options[obj.selectedIndex].innerText;
var ajax = BuildAjaxModel();
ajax.onreadystatechange=function(data)
{
if(ajax.readyState==4)
{
data = ajax.responseText;
alert(data);
}
}
ajax.open("GET","doRender.aspx?id="+oi,true);
ajax.send(null);
}
function BuildAjaxModel()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Cant Build AJAX!");
return false;
}
}
}
return xmlHttp;
}
</script>
TA贡献1828条经验 获得超13个赞
<select onchange="go(this.value);">
<option value="1" selected>1</option>
<option value="2">2</option>
</select> <script>go(val){ if(val==1) go_1(); else if(val==2) go_2(); }</script>
添加回答
举报