最近做项目要用到级联下拉框联动,一开始用的是doubleselect,标签虽然挺好用,但是表单数据往后台传输,太困难了,没做出来,然后换的select下面
jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/common/common.jsp"%>
<%@page import="com.archive.entity.Role"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function findchild(){
var sta=document.getElementById("cname").value;
var url="<%=basePath%>system/promptAction!getdn.action?cname="+sta;
$.ajax({
url:"<%=basePath%>system/promptAction!getdn.action", //请求的url地址
dataType:"text", //返回格式为json
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
cache: true,
data:{
"cname":sta}, //参数值
type:"POST", //请求方式
success:function(req){
arr=req.split(",");$("#dname");
for(var i=0;i<arr.length;i++){
$("#disname").append('<option value='+arr[i]+'>'+arr[i]+'</option>');
}
},
error:function(req){
alert("请求出错!请重新请求"