您的位置:首页 > 其它

工作三个月中常用的一些东西

2016-01-20 08:37 381 查看
1单选框打钩

$("#dyli12").attr("checked", true);//打勾

2定义一个tab标签

<div class="easyui-tabs" id="Tabs">

<div title=”tab标签名”></div>

<div title=“”></div>

</div>

3tab标签的选择改变事件

$("#Tabs").tabs({

onSelect: function (title, index)

{

if(index==0)

{第一个选项卡被选中}

If(index==1)

{第二个选项卡被选}

}})

4在框架中被引用页面获取父页面中中id为policy的元素的值

$("#PolicyNo", window.parent.document).val();

5在父页面中获取框架name属性为IframeName中id为testId的元素的值

$(window.frames["iframeName"].document).find("#testId").val()

6获取下拉框中的当前值

var BatchNumber = $(this).val(); //获取下拉框选中的值

7新建一个窗口,开始的时候是关闭的,窗口里面放的是一个框架

<div id="win1" class="easyui-window" title="Message" data-options="modal:true,iconCls:'icon-save',maximized:true" closed="true" style="width: 720px; height: 500px; padding: 10px;">

<iframe id="myIframe" style="border: none; width: 99%; height: 99%"></iframe>

</div>

8关闭一个jquery easyui中的win窗体

$("#win1").window('close');

9动态的给窗体设置标题

$("#win1").window({title:"被保险人事项"});//设置窗体的标题

10js中给变量转码,解决中文乱码问题

escape()

11jquery easyui中datebox控件的操作

$("#id").datebox('setValue',值); //给jquery日期控件赋值

$(“#id”).datebox(‘getValue’)//获取日期控件的值

$("#zjbx_qsrq3").datebox({ disabled: true });

12设置几秒后刷新

function Reload(){

location.reload();

}

setTiemout(“Reload()”,2000); //jquery刷新页面

Parent.location.reload() //juquery刷新父页面

13循环遍历json数组

for (var key in data[0])

{

//alert(key + ':' + data[0][key]); //遍历json数组

$("#" + key + "").val(data[0][key]);

}

//遍历json

$.each(data,function(key,value){

})

14jquery easyui中gridview用法

$(function () {

$("#wind").window('close');

$("#wind1").window('close');

InitGrid('');

var p = $('#list').datagrid('getPager');

$(p).pagination({

pageSize: 10,//每页显示的记录条数,默认为5

pageList: [5, 10, 15, 20, 25, 30],//每页显示几条记录

beforePageText: '第',//页数文本框前显示的汉字

afterPageText: '页 共 {pages} 页',

displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',

onBeforeRefresh: function () {

$(this).pagination('loading');//正在加载数据中...

$(this).pagination('loaded'); //数据加载完毕

}

});

});

function InitGrid(searchStr) {

$('#list').datagrid({

width: 'auto',

height: 320,

striped: true,

singleSelect: true,

url: '/Extend Class/PersonalInsuranceFinance.ashx?action=ProjectCollectionList' + searchStr,

loadMsg: '数据加载中请稍后……',

pagination: true,

rownumbers: true,

pageSize: 10,

pageList: [5, 10, 15, 20,25,30],

columns: [[

{ field: 'Id', title: 'Id', width: 120, hidden: true },

{ field: 'Number', title: '收款项目编号', width: 120, align: 'center' },

{ field: 'AccountReceivables', title: '收款部门', width: 120, align: 'center' },

{ field: 'AccountProject', title: '收款项目', width: 120, align: 'center' },

{ field: 'PaymentAmount', title: '收款金额', width: 120, align: 'center' },

{ field: 'AccountingStatus', title: '结算状态', width: 120, align: 'center' },

{ field: 'Applicant', title: '操作', width: 120, align: 'center', formatter: function (value, row, index) { return TooptipFormatter(value, row, index); } }

]]

});

}

function TooptipFormatter(value, row) {

return '<a href="javascript:void(0);" class="easyui-tooltip" style="color:#0044BB;text-decoration:none;" onclick="OpenResearchForm(' + row.Id + ')">【收款】</a>';

}

function OpenResearchForm(id) {

$("#wind").window('open');

$("#ID").val(id);

}

//datagrid中获取选中的一样

var row = $('#list').datagrid('getSelected');

//获取选中一样中id列的值

row.id

15sql 已数据库中实际的行做为row

select *,ROW_NUMBER() over(order by VisitDate desc) as rows from yw_010101 where Userid={0} and ExamID={1} order by VisitDate desc

//jquery获取id为BusinessId的控件的值,将值已,分割,[0]表示16此处是已‘,’分割字符串为数组取第一段

var 变量= $("#id").val().split(',')[0];

17juqery发送ajax请求

$.ajax({

url:“”,//ajax请求的地址

data:{action:’’,} //ajax发起请求时,向服务器提交的数据

datatype:’json’,//ajax提交数据的格式,已json格式提交

type:’post’,//提交方式为post提交

timeout:60000,//超时时间

success:function(data) //请求成功后会掉的函数

{

var id =data[0][“id”]//取json中的值

}

})

18创建object对象,然后通过json格式插件,将其格式化

var data= new object[]{

new {

dyliName=dyliName,

shenfenzhen=shenfenzhen,

sex=sex,

birthday=birthday,

marryState=marryState,

zhiyedaima=zhiyedaima,

address=address,

phone =phone

}

};

string datajson = JsonConvert.SerializeObject(data);

context.Response.Write(datajson);

19 JS 获取URL参数方法

function getQueryString(name) {

var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");

var r = window.location.search.substr(1).match(reg);

if (r != null) return unescape(r[2]); return null;

}

20通过代码向datatable中添加一行

DataTable result = new DataTable();

DataRow resultRow = result.NewRow();

result.Columns.Add("Err_Code", typeof(Int32));

result.Columns.Add("Err_Desc", Type.GetType("System.String"));

21checkbox只能单选

$(":checkbox").click(function () {

if ($(this).is(":checked")) {

$(":checkbox").attr("disabled", true);

$(this).attr("disabled", false);

}

else {

$(":checkbox").attr("disabled", false);

}

})

22正则表达式教程

http://deerchao.net/tutorials/regex/regex.htm#mission

23jquery easyui中关闭tab的项

$("#openTabs").tabs('close', '用工信息');

#openTabs是tab的id

用工信息:为要关闭的标签的title

24禁用日期框的一种方法

$("#t_c td").eq(1).find('input').attr('disabled', 'disabled'); //禁用日期框,先给配置的表格中日期框所在行的tr给个id然后找到日期框所在的行,禁用掉输入

25校验身份证

function checkIdCard(obj) {

if ((/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(obj)) || (/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/.test(obj))) {

return true;

}

else {

return false;

}

}

26校验日期

function CheckDateTime(str) {

var pattern = /((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))/;

if (pattern.test(str)) {

return true;

}

else {

return false;

}

}

27校验必须为数字

function CheckNum(str) {

var pattern = /^[0-9]*$/;

if (pattern.test(str)) {

return true;

}

else {

return false;

}

}

28禁用掉按钮的点击事件

$("#id").removeAttr('onclick');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: