发布于 2016-09-29 22:43:27 | 142 次阅读 | 评论: 0 | 来源: 网友投递
jQuery javascript框架
jQuery是一个兼容多浏览器的javascript框架,核心理念是write less,do more(写得更少,做得更多)。jQuery在2006年1月由美国人John Resig在纽约的barcamp发布,吸引了来自世界各地的众多JavaScript高手加入,由Dave Methvin率领团队进行开发。
<head><title>jquery实现动态加载select下拉选项</title>
<script type="text/javascript">
function init(){
makemoduleSelect();
}
//加载模板下拉框选项
function makemoduleSelect(){
$.ajax({
url : 'indexStatisticsAction_getSelect.jsp',
data: { page:'clientindexStatistics.jsp',method:'get_modtitlecode'},
success : function(result){
$("#makemodule").append(result);
}
});
}</script>
</head>
<body onload="init()">
下拉框<select name="makemodule" id="makemodule" style='width:130px' onchange='makemoduleSelected()'>
<option> ------- </option>
</select></body>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.io.PrintWriter"%>
<%
String userId = (String) session.getAttribute("userid");
String method = request.getParameter("method");
String fromPage = request.getParameter("page");
String sql1 = "select modtitlename,modtitlecode from makemodule where userid = '?userId?' and modulename_en='?modulename_en?' group by modtitlename ";
System.out.println("---getting select_option from:"+fromPage+"----" + new Date());
//获取模板选项
if(method.equals("get_modtitlecode")){
String sql = sql1.replace("?userId?",userId);
if(fromPage.equals("acindexStatistics.jsp")){
sql = sql.replace("?modulename_en?","acsta");
}else if(fromPage.equals("apindexStatistics.jsp")){
sql = sql.replace("?modulename_en?","apsta");
}else if(fromPage.equals("clientindexStatistics.jsp")){
sql = sql.replace("?modulename_en?","terminalsta");
}
System.out.println(sql);
StringBuffer rsOption = new StringBuffer();
Db db = new Db();
try {
db.prepareQuery();
ResultSet rs = db.executeQuery(sql);
while (rs!=null && rs.next()) {
rsOption.append("<option value='"+rs.getString("modtitlecode")+"'>"+StringOperator.ISO2GB(rs.getString("modtitlename"))+"</option>");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
db.endQuery();
}
PrintWriter pout = response.getWriter();
pout.write(rsOption.toString());
pout.flush();
pout.close();
}
%>