日期:2014-05-16  浏览次数:20980 次

Jquery+Ajax 联动刷新被重置 - Web 开发 / Ajax
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>  
  <title>My JSP 'select.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
$("select[name='bdsdm']").change(function(){
var bdsdm = $("select[name='bdsdm']").attr("value");
if(bdsdm!=''){
$.ajax({
type:'get',
url:'GetSize.do?bdsdm='+bdsdm,
cache:false,
success:function(data){
$("select[name='jgdm']").empty();
$("select[name='jgdm']").css("width","200px");
$("<option value=''>--请选择--</option>").appendTo("select[name='jgdm']");
var map = eval("("+data+")");
$.each(map,function(key,value){
$("<option value="+value+">"+key+"</option>").appendTo("select[name='jgdm']");
})
}
});
  }else{
  $("select[name='jgdm']").empty();
  $("select[name='jgdm']").css("width","");
  $("<option value=''>--请选择--</option>").appendTo("select[name='jgdm']");
  }
});


$('#check').click(function(){

document.forms[0].submit();

});
  </script>
 
  </head>
  
  <body>
  <form style="float:left">
  <table>
<tr>
<td>
<html:select property="bdsdm" >
<html:option value="">--请选择--</html:option>
<html:option value="1">1</html:option>
<html:optionsCollection label="label" value="value" property="bdsList"/>
</html:select>
 
</td>
<td>
<html:select property="jgdm">
<html:option value="">--请选择--</html:option>
<logic:notEmpty property="jgList" name="spsbkBean">
<html:optionsCollection label="label" value="value" property="jgList"/>
</logic:notEmpty>