ajax异步传值实现二级联动效果实例:
function initorg(id) {
$.ajax({
type:"post",
url:"${ctx}/html/machinemode/machinemode!selectSeriesByid.action?id="+ encodeURIComponent(encodeURIComponent(id))+"&a="+Math.random(),
async:false,
success:function(json){
alert(json); //接受的是表单
document.getElementById("pinpai").innerHTML=json;
}
})
}
系列和品牌做级联效果:
系列 | 品牌 |
Pc | Pc |
平板 | 飞触 |
云客 |
<tr>
<th>系列:</th>
<td><select name="series" οnchange="initorg(this.value);">
<option value="-1">请选择</option>
<s:iterator id="serList" value="#request.serList">
<option value="<s:property value="#serList.stateValueName" />">
<s:property value="#serList.stateValueName" />
</option>
</s:iterator>
</select>
</td>
</tr>
<tr>
<th>品牌:</th>
<td><div id="pinpai" name="pinpai"><select name="machinename">
<option value="-1">请选择</option>
<s:iterator id="mnList" value="#request.mnList">
<option value="<s:property value="#mnList.stateValueName" />">
<s:property value="#mnList.stateValueName" />
</option>
</s:iterator>
</select></div>
</td>
</tr>
还有一点:注意引用jquery相关js文件!