2011-07-10 45 views
0

我有一個jQuery的jQueryUI日期選擇器在網站上。選擇日期後,我想在不同的div中顯示日期,例如:我想從jQuery datepicker獲取日期作爲文本返回

1)人員在輸入框中選擇日期和日期,然後, 2)新的div顯示並顯示提供 '挑選(選中日期)時間:'

的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> 

時間將來自單獨的源中列出。

請明確。

+0

1.顯示你有什麼,2.你使用什麼datetimepicker。 3.明確! – Luke

回答

0

爲什麼不使用這個插件將jQuery UI的日期選擇器。 http://trentrichardson.com/examples/timepicker/它允許選擇日期和時間。良好的文檔和乾淨的UI。

+0

我已經看過。只有在選擇日期後,纔會從其他來源提取時間。這是爲了讓某人從特定日期選擇特定時間,因此,如果某人選擇了「星期天」,則會顯示零個可用時間。但如果他們選擇「星期二」,並且只有少數時間段可用,那麼只有那些時間纔會顯示。 – Adam

相關問題