开发者

I would like to get date from jQuery datepicker returned as text

开发者 https://www.devze.com 2023-03-19 00:29 出处:网络
I have a jQuery\'s jQueryUI datepicker on a site. After the person chooses a date, I would like to display the date as text in a different div, such that:

I have a jQuery's jQueryUI datepicker on a site. After the person chooses a date, I would like to display the date as text in a different div, such that:

1) Person chooses date and date appears in input box, then, 2) A new div shows and offers 'Pick a time on (selected date):'

jQuery:

<script type='text/javascript'>
 $(function(){
      $('.date_panel,.time_panel').hide();

      $('.svc_button').click(function(){
            $('.svc_panel').fadeOut(function(){
            $('.date_panel').fadeIn();
            });
      });

      $('.time_button').click(function(){
            $('.time_panel').fadeIn(开发者_开发百科function(){
            });
      });

});
</script>

<script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
</script>

html:

</div>

<div class="date_panel">

<p>Click here to pick a date: <input id="datepicker" class="time_button" type="text"></p>

</div>

<div class="time_panel">

<p>Pick a time on: <script type="text/javascript">document.write("<span>" + .datepicker( "getDate" ) + "</span>");</script></p>

The time will be listed from a separate source.

Please, be explicit.


jQuery('#datepicker').bind('change',function(){
              jQuery('#target').html(jQuery(this).val())
})

http://jsfiddle.net/5PqQb/


http://jqueryui.com/demos/datepicker/

tried to work with the "onSelect" event?

$('.selector').datepicker({
   onSelect: function(dateText, inst) { ... }
});


Why not use this addon to jquery-ui datepicker. http://trentrichardson.com/examples/timepicker/ It allow for the date and time to be picked. Good documentation and clean UI.

0

精彩评论

暂无评论...
验证码 换一张
取 消