0

Line: 670 which is startdate.value = hiddenstart.value;
But I am getting an unaught TypeError:
Cannot read property 'value' of null in the javascript console.
问题是这只发生在 Chrome 中,没有其他浏览器。

有人可以看看,让我知道是否有什么我可以改变来解决这个问题。

<script language="Javascript">
   function calcEndDate(cal) {
   var startdate = document.getElementById("<?php echo columnnames($value); ?>_0");
   var hiddenstart = document.getElementById("hiddenstart");
   startdate.value = hiddenstart.value;
   var date = cal.date;
   var time = date.getTime();
   var hiddenend = document.getElementById("hiddenend");
   var date2 = new Date(time);
   hiddenend.value = date2.print("%d-%b-%Y 23:59");
   var enddate = document.getElementById("<?php echo columnnames($value); ?>_1");
   enddate.value = hiddenend.value;
   return true;
}

function calcUpdateEndDate() {
  var enddate = document.getElementById("<?php echo columnnames($value); ?>_1");
  var hiddenend = document.getElementById("hiddenend");
  enddate.value = hiddenend.value;
}
</script>
<table cellpadding="0" cellspacing="3" border="0">
<tr>
<td><input type="text" class="standardfield_date_srch" name="<?php echo   columnnames($value); ?>_0" value="<?php echo $dateoutput0 ?>"></td>
<td><img src="/images/icons/calendar.png" id="<?php echo columnnames($value); ?>0" style="cursor: pointer;" title="Date selector"></td>
<td><input type="hidden" class="standardfield_date_srch" name="hiddenstart" value="             <?php echo date("d-M-Y",time()) ?> 00:00"> 
    <script language="javascript">Calendar.setup({    inputField:"hiddenstart",button:"<?php echo columnnames($value); ?>0",align:"Ll00", ifFormat:"%d-%b-%Y %H:%M", showsTime: true, onUpdate : calcEndDate});</script>
</td>
</tr>
<tr>
  <td><input type="text" class="standardfield_date_srch" name="<?php echo columnnames($value); ?>_1" value="<?php echo $dateoutput1 ?>"></td>
    <td><img src="/images/icons/calendar.png" id="<?php echo columnnames($value); ?>1" style="cursor: pointer;" title="Date selector" >
    <td><input readonly type="hidden" class="standardfield_date_srch" name="hiddenend"> 
    <script language="javascript">Calendar.setup({ inputField:"hiddenend",button:"<?php echo columnnames($value); ?>1",align:"Ll00", ifFormat:"%d-%b-%Y %H:%M",showsTime:true, onUpdate : calcUpdateEndDate});</script>
</td>
</tr>
</table>  

给我一些提示或指导我哪里错了。

4

1 回答 1

0

您正在尝试通过 id 访问隐藏字段,但由于没有设置 idhiddenstart并且hiddenend为空。

<input type="hidden" class="standardfield_date_srch" name="hiddenstart" id="hiddenstart" value="<?php echo date("d-M-Y",time()) ?> 00:00" />
<input type="hidden" class="standardfield_date_srch" name="hiddenend" id="hiddenend" />
于 2012-09-27T11:00:26.907 回答