已结贴√
问题点数:20 回复次数:9
jquery动态增减控件如何才能不刷新页面
用jquery动态管理控件,可是每一次增减控件都会刷新页面,然后控件里面原来输入的值就都不在了,可以怎么来实现在动态增减控件时不刷新页面呢?
function addSections(position) {
var all_list = [];
for (var i = 0; i < sctionCount; i++) {
var sectionName = "#sctionName" + (i + 1);
var sectionJoin = "#sectionJoin" + (i + 1);
var sectionJoinID = "#sectionJoinID" + (i + 1);
var sectionDesc = "#sectionDesc" + (i + 1);
var sectionstart = "sectionstart" + (i + 1);
var sectionend = "#sectionend" + (i + 1);
var name = $(sectionName).val();
var Desc = $(sectionDesc).val();
var Join = $(sectionJoin).val();
var start = $(sectionstart).val();
var end = $(sectionend).val();
var value = {
'sectionName': name,
'sectionJoin': Join,
'sectionDesc': Desc,
'sectionstart': start,
'sectionend': end
}
all_list.push(value);
if (position == i) {
var value = {
'sectionName': "",
'sectionJoin': "",
'sectionDesc': "",
'sectionstart': "",
'sectionend': ""
}
all_list.push(value);
}
}
sctionCount += 1;
var sctiontable = "
sctiontable += "
";sctiontable += "
阶段名称";sctiontable += "
参与人";sctiontable += "
描述";sctiontable += "
开始日期";sctiontable += "
结束日期";sctiontable += "
操作";sctiontable += "
";for (var i = 0; i < sctionCount; i++) {
var sectionName = "sctionName" + (i + 1);
var sectionJoin = "sectionJoin" + (i + 1);
var sectionJoinID = "sectionJoinID" + (i + 1);
var sectionDesc = "sectionDesc" + (i + 1);
var sectionstart = "sectionstart" + (i + 1);
var sectionend = "sectionend" + (i + 1);
var sectionadd = "sectionadd" + (i + 1);
var sectionDelete = "sectionDelete" + (i + 1);
var sectionClose = "sectionClose" + (i + 1);
var classid = "table-clo-tr" + (i % 2 + 1);
var sectionnametip = "sectionnametip" + (i + 1);
var sectionJointip = "sectionJointip" + (i + 1);
var sectiondesctip = "sectiondesctip" + (i + 1);
var sectionstartTip = "sectionstartTip" + (i + 1);
var sectionendTip = "sectionendTip" + (i + 1);
sctiontable += "
";sctiontable += "
" + "" +"*" + "
";sctiontable += "
" + "" +"*" +
"" + "
";sctiontable += "
" + " " +"*" + "
";sctiontable += "
" + "" +"*" + "
";sctiontable += "
" + "" +"*" + "
";sctiontable += "
" + "" +"" + "
";sctiontable += "
";}
sctiontable += "
";$("#Sctions").html(sctiontable);
}