Jquery相关插件
2024-10-18 04:57:36
$("#AccountNames").autocomplete(Accounts, {
minChars: 0,
matchContains: true,
mustMatch: false,
multiple: true,
multipleSeparator: ',',
formatItem: function (row, i, max) {
if ($("input[name='AccountIds'][value=" + row.AccountId + "]").size() == 0) {
if (row.FullName!=row.AccountName)
return row.AccountName + "(" + row.FullName + ")";
else
return row.AccountName;
} else {
return false;
}
},
formatMatch: function (row, i, max) {
if (row.FullName!=row.AccountName)
return row.AccountName + "(" + row.FullName+")";
else
return row.AccountName;
},
formatResult: function (row) {
return row.AccountName;
}
}).result(function (event, data, formatted) {
if(data){
$("<input name=\"AccountIds\" type=\"hidden\" />").val(data.AccountId).appendTo("#SpendExportForm");
} }).blur(function () {
var accName = $(this).val();
$("input[name=AccountIds]").each(function(){
var id=parseInt($(this).val());
var name=$.grep(Accounts,function(row){return row.AccountId==id;})[0].AccountName;
if(!new RegExp("(^"+name+",)|(,"+name+",)","i").exec(accName)){
$(this).remove();
}
});
return true;
}).keyup(function () {
if($.trim($(this).val())==""){
$("input[name=AccountIds]").remove();
}
});
数组的处理
var idsa=[];
$("input[name=AccountIds]").each(function(){
idsa.push($(this).val());
});
var d = $("#WalletIds").select2('data');
var idsw = $.map(d, function (v, i) {
return v.id;
});
正则的处理
if(!new RegExp("(^"+name+",)|(,"+name+",)","i").exec(accName)){
$(this).remove();
}
数组过滤
var name=$.grep(Accounts,function(row){return row.AccountId==id;})[0].AccountName;
form隐藏域,form提交
$("#SpendExportForm").html("");
var d = $("#WalletIds").select2('data');
var ids = $.map(d, function (v, i) {
$("<input type=\"hidden\" name=\"WalletIds\" />").val(v.id).appendTo("#SpendExportForm");
}); $("input[name=AccountIds]").each(function(){
$("<input type=\"hidden\" name=\"AccountIds\" />").val($(this).val()).appendTo("#SpendExportForm");
}); $("<input type=\"hidden\" name=\"showAdDistribution\" />")
.val( $("#showAdDistribution")[0].checked).appendTo("#SpendExportForm"); $("#SpendExportForm").submit();
最新文章
- Spring学习记录(二)---容器和bean属性配置
- [Android]官网《UI/Application Exerciser Monkey》中文翻译
- 引用iScroll.js实现上拉和下拖刷新
- jQuery知识点总结(第四天)
- 使用canvas绘制时钟
- igbinary vs serialize vs json_encode
- HTML页面实现返回顶部效果 go to top
- 利用java读写Excel文件
- c#与vb.net在App_Code里面编译要通过,需要以下web.config的配置
- Ecshop布局参考图
- ant_0105
- 修改wampsever默认密码
- Redis的使用初探
- NB学校的NB课程的NB教材——CSAPP
- [硬件]_ELVE_STLINK下载出现nternal command error问题
- Other Problems
- 字符串全部转换为大写用str.toUpperCase()方法
- 用mac的chrome浏览器调试Android手机的网页
- DOS 配置IP地址
- 【Android】ProgressBar