demo.js放在最后说,先说PatentDataBdSearch 对输入框发送过来的数据进行处理,时间段查询数据库
demo.js 实现数据检测,模拟回车操作
<div class="jb51code">
<pre class="brush:js;">
$(function(){
/
define a new language named "custom" 插件设置
/
$.dateRangePickerLanguages['custom'] =
{
'selected': 'Choosed:','days': 'Days','apply': 'Close','week-1' : 'Mon','week-2' : 'Tue','week-3' : 'Wed','week-4' : 'Thu','week-5' : 'Fri','week-6' : 'Sat','week-7' : 'Sun','month-name': ['January','February','March','April','May','June','July','August','September','October','November','December'],'shortcuts' : 'Shortcuts','past': 'Past','7days' : '7days','14days' : '14days','30days' : '30days','prevIoUs' : 'PrevIoUs','prev-week' : 'Week','prev-month' : 'Month','prev-quarter' : 'Quarter','prev-year' : 'Year','less-than' : 'Date range should longer than %d days','more-than' : 'Date range should less than %d days','default-more' : 'Please select a date range longer than %d days','default-less' : 'Please select a date range less than %d days','default-range' : 'Please select a date range between %d and %d days','default-default': 'This is costom language'
};
//下面设置称自己的输入框选择器
$("input[name='PatentDataBdSearch[issued]']").dateRangePicker(
{
//时间段的类型设置,这里是输入框时间段以~分隔,选择时间后自动消失弹出框
separator : ' ~ ',autoClose: true
}).bind('datepicker-change',function(e,r)
{
try
{
console.log(r);
//重要:如果检测有输入值了,就在输入框显示光标,或者模拟回车事件,自动提交,像gridview原生功能
//不添加下面的代码,将无法自动提交,
var issued=$("input[name='PatentDataBdSearch[issued]']").val();
console.log(issued);
if(issued){
//输入之后显示光标
//$("input[name='PatentDataBdSearch[issued]']").focus();
//模拟回车操作,输入后自动提交,刷新数据,一定要设置时间计数器,否则将无法提交
setTimeout(function(){
e = jQuery.Event("keydown");
e.keyCode = 13; //enter key
jQuery("input[name='PatentDataBdSearch[issued]']").trigger(e);
},100);
}
}catch(e){}
});
});
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。
本站采用系统自动发货方式,付款后即出现下载入口,如有疑问请咨询在线客服!
售后时间:早10点 - 晚11:30点