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条)

报告相同问题?

悬赏问题

  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验