亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquery自動(dòng)填充勾選框即把勾選框打上true

 更新時(shí)間:2014年03月24日 17:10:00   作者:  
jquery自動(dòng)填充勾選框,即把勾選框打上(true),然后通過ajax方式獲得勾選項(xiàng)列表,再把列表內(nèi)的選項(xiàng)打上
jquery自動(dòng)填充勾選框,即把勾選框打上(true),然后通過ajax方式獲得勾選項(xiàng)列表,再把列表內(nèi)的選項(xiàng)打上。
復(fù)制代碼 代碼如下:

下拉框<select name="makemodule" id="makemodule" style='width:130px' onchange='makemoduleSelected()'>
<option value='1'>1</option>
</select>

select改變,觸發(fā)函數(shù)makemoduleSelected(),該函數(shù)如下:
復(fù)制代碼 代碼如下:

//模板下拉框發(fā)生變化時(shí),觸發(fā)此事件(onchange)。
function makemoduleSelected(){
clearAll('property');
var modtitlecode = $("#makemodule").val();
$.ajax({
url : 'indexStatisticsAction_getSelect.jsp',
data: { page:'clientindexStatistics.jsp',method:'get_subname_en',modtitlecode:modtitlecode},
success : function(result){
// 根據(jù)result返回信息判斷是否登錄成功
var results = result.split(",");
//document.getElementById(results[i]).checked = true;
$(".indexStatistics").each(function(){
$(this).find("input").each(function(){
var tempVal = $(this).val();
for(var i=0; i<results.length; i++){
if(tempVal == results[i]) $(this).attr("checked", true);
}
});
});
}
});
}

該函數(shù)通過ajax方式向indexStatisticsAction_getSelect.jsp發(fā)出請(qǐng)求,返回一個(gè)字符串,把改字符串分開成字符串?dāng)?shù)組,接下來遍歷標(biāo)簽<div class="indexStatistics">下面的標(biāo)簽,遇到相關(guān)的標(biāo)簽,則打鉤(true)。indexStatisticsAction_getSelect.jsp的相關(guān)代碼如下:
復(fù)制代碼 代碼如下:

//獲取模板對(duì)應(yīng)的指標(biāo)
if(method.equals("get_subname_en")){
String modtitlecode = request.getParameter("modtitlecode");
if(modtitlecode.equals("-------")) return;
String sql = sql2.replace("?modtitlecode?",modtitlecode);
sql = sql.replace("?userId?",userId);
System.out.println(sql);
StringBuffer subnames = new StringBuffer();
Db db = new Db();
try {
db.prepareQuery();
ResultSet rs = db.executeQuery(sql);
while (rs!=null && rs.next()) {
subnames.append(rs.getString("subname_en"));
subnames.append(",");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
db.endQuery();
}
PrintWriter pout = response.getWriter();
pout.write(subnames.toString().substring(0,subnames.length()-1));
pout.flush();
pout.close();
}

相關(guān)文章

最新評(píng)論