国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jquery自動填充勾選框即把勾選框打上true

2019-11-20 20:54:55
字體:
來源:轉載
供稿:網友
jquery自動填充勾選框,即把勾選框打上(true),然后通過ajax方式獲得勾選項列表,再把列表內的選項打上。
復制代碼 代碼如下:

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

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

//模板下拉框發生變化時,觸發此事件(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){
// 根據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);
}
});
});
}
});
}

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

//獲取模板對應的指標
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();
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 雷州市| 米泉市| 海南省| 崇州市| 怀柔区| 海盐县| 鄂尔多斯市| 红河县| 萨迦县| 永寿县| 吉林市| 丰都县| 磴口县| 卓资县| 长治市| 舒城县| 南澳县| 错那县| 长兴县| 阿坝县| 娄底市| 广丰县| 东丰县| 辰溪县| 神池县| 梓潼县| 读书| 南皮县| 陆河县| 康保县| 隆安县| 青海省| 满城县| 讷河市| 丽水市| 任丘市| 慈利县| 油尖旺区| 乌鲁木齐县| 临漳县| 石泉县|