dongyi5817 2014-08-21 13:47
浏览 42
已采纳

带有隐藏输入的多个JQuery Datepicker

I'm using a variable number of datepicker on my page.

Every datepicker must be always visible and I don't want to display the input field.

foreach ($array as $k =>$z) {
  echo "<div id='datepicker".$k."'></div>
        <input name='dates[]' id='datepicker_input".$k."' type='hidden' >";
}   

javascript

<script>
$(document).ready(function() {
 <?php
      foreach ($array as $k => $z) {
          echo "$('#datepicker".$k."').datetimepicker({      
              format:'d.m.Y H:i',
              inline:true,
              lang:'en'
          });";
      }
 ?>
});
</script>

My Goal is to send all the dates using a form, so that when I click to my submit button I can retrieve every dates from _POST. Unfortunately, the dates array I retrieve contains empty arrays.

I dont know how to bind the datepicker inline with my hidden fields... I need to update the hidden input fields with the selected values.

Maybe I'll have to use JSON, but I'm not sure of what to do.

Thanks

  • 写回答

2条回答 默认 最新

  • du512053619 2014-08-21 14:44
    关注

    Check this fiddle: http://jsfiddle.net/pms2juab/3/

    HTML:

    <input name='dates[]' id='datepicker1' class="datepicker" type='hidden' />
    <input name='dates[]' id='datepicker2' class="datepicker" type='hidden' />
    <input name='dates[]' id='datepicker3' class="datepicker" type='hidden' />
    <input name='dates[]' id='datepicker4' class="datepicker" type='hidden' />
    <input name='dates[]' id='datepicker5' class="datepicker" type='hidden' />
    

    JS:

    $(function(){
       $('.datepicker').each(function(i,k){
       $(this).datetimepicker({      
                  format:'d.m.Y H:i',
                  inline:true,
                  lang:'en'
              });
       });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大