Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我的值在datepicker中有时被读取,有时被忽略_Javascript_Jquery_Visibility - Fatal编程技术网

Javascript 我的值在datepicker中有时被读取,有时被忽略

Javascript 我的值在datepicker中有时被读取,有时被忽略,javascript,jquery,visibility,Javascript,Jquery,Visibility,这是它的总和: <script> //hard coded these to simplify my code var startDate = '01-01-2013'; var endDate = '01-31-2013'; $(document).ready(function() { $('#ReportStartDays').val(startDate); $('#ReportEndDays').val(endDate); } jQuery('#Report

这是它的总和:

<script>
//hard coded these to simplify my code
var startDate  = '01-01-2013';
var endDate    = '01-31-2013';

$(document).ready(function() {
  $('#ReportStartDays').val(startDate);
  $('#ReportEndDays').val(endDate);
}

jQuery('#Report').jqGrid({
//Sometimes these grab the right values, and sometimes it doesn't
//ReportStartDays.val();
//ReportEndDays.val()
});
</script>

//硬编码以简化我的代码
var startDate='01-01-2013';
var截止日期='01-31-2013';
$(文档).ready(函数(){
$(#ReportStartDays').val(startDate);
$(#ReportEndDays').val(endDate);
}
jQuery(“#报告”).jqGrid({
//有时,它们抓住了正确的值,有时却没有
//ReportStartDays.val();
//ReportEndDays.val()
});

有人知道为什么我的报表输入不能正常工作吗?有时它会捕获它们,有时则不会。如果我将
startDate
endDate
放在ready函数中,那么出于某种原因,它们的初始化速度不够快,无法从jQuery函数读取新值。有什么想法吗?

尝试将代码包装在中de>$(窗口)。改为加载(函数)

$(window).load(function() {
  var startDate  = '01-01-2013';
  var endDate    = '01-31-2013';


  $('#ReportStartDays').val(startDate);
  $('#ReportEndDays').val(endDate);

  startDate = $('#ReportStartDays').val();
  endDate = $('#ReportStartDays').val();    

  $('#Report').jqGrid({
     'some_param' : startDate,
     'some_param' : endDate
  });
});
我确实创建了一个提琴示例。因为我没有执行
jqGrid
方法,所以我只是在HTML中添加了一些值来尝试和演示

我还假设,当您引用方法
jqGrid
时,您正在将这些值应用于参数,在这种情况下,您可以尝试使用全局变量


无论如何-这个想法应该在ballpark中

中,而不发布所有代码,就不可能调试任何东西。请尝试在a内部重新创建问题,以便我们查看。提供HTML标记。