javascript - how i will extract month and year from month year picker,i am using jquery -


i want month , year seperate month/year picker. tried this.

i want insert month , year database,for want seperate.i using codeigniter frame work

var month= $("#ui-datepicker-div .ui-datepicker-month :selected").val();         window.write(' month'); 

its not working.

<!--<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">--> <script src="../monthyear/jquery-ui.js"></script> <link rel="stylesheet" href="jquery-ui.css"> <label for="monthyearpicker">date :</label> <div class="monthyearpicker" name="mydate" ></div> <!--<input name="mydate" class="monthyearpicker" />-->      <script>   $(document).ready(function () {     $(function () {         $('.monthyearpicker').datepicker({             changemonth: true,             changeyear: true,             showbuttonpanel: true,             dateformat: 'mm yy'         }).focus(function () {             var thiscalendar = $(this);             $('.ui-datepicker-calendar').detach();             $('.ui-datepicker-close').click(function () {                 var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();                 var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();                 thiscalendar.datepicker('setdate', new date(year, month, 1));             });         });     }); }); </script> <style>     .ui-datepicker-calendar {    visibility:hidden; }</style> 

use onclose() method of datepicker.

onclose: function(datetext) {             datevariable = datetext;            if(datevariable != null && datevariable != ""){                 var arr = datevariable.split(' ');                 $('#month').val(arr[0]);                 $('#year').val(arr[1]);            } 

example : jsfiddle

i hope solve problem.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -