2016-11-02 115 views
0

我使用jquery jquery-1.9.1.min.js。我有以下的JSP與一個datepickerJQuery datepicker顯示月份下拉列表change月份

<script type="text/javascript"> 

     $(function() { 
      $("#datepicker1").datepicker({ 
       changeMonth: true, 
       changeYear: true, 
       defaultDate: new Date('2016','11','02'), 
      setDate: new Date('2016','11','02') 
      }); 
      }); 

</script> 
</head> 
<body> 
    <%@include file="../menu/cabeceraMenu.jsp"%> 
    <%@include file="../menu/opcionesEncuesta.jsp"%> 
    <form action="${pageContext.request.contextPath}/encuesta/nueva" 
     name="frm" id="nueva-encuesta" method="post" style="margin: 0px;"> 
     <table class="tablaCentral"> 
      <tr> 
     <td> 
     Date: <input type="text" id="datepicker1"> 
     </td> 
     </tr> 
     </table> 

</body> 
</html> 

這是輸出屏幕

enter image description here

我怎樣才能在屏幕dropdrown框顯示月份名稱和編號的一年。現在他們是空的。

日期是 新的日期( '2016', '11', '02')去除defaultDatesetDate後 我想與11月成立箱和2016年

+0

你使用的jQuery UI的版本?和主題? – Aroniaina

+0

jquery-1.9.1.min.js –

+0

只有jquery沒有datepicker,你必須使用jQuery UI和主題,如果你想! (就像你回答@CharantejGolla) – Aroniaina

回答

1

嘗試。

$(function() { 
 
    $("#datepicker1").datepicker({ 
 
     changeMonth: true, 
 
     changeYear: true 
 
    }); 
 
    });
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
 
<input type="text" id="datepicker1">

+0

我刪除了changeMonth和changeYear,但我沒有看到月份名稱和年份。我使用Firefox。我檢查了你的腳本,現在它工作。非常感謝 – user3712581

相關問題