Need Jquery Datepicker to show "Month" and "Year" as text in dropdown list -
this need. select menus contain words "year" , "month". (usually please select)
demo 1: - jsfiddle1
but should run text box demo1.
demo 2: - jsfiddle2
if change last line in source code posted
<div id="datepicker"></div>
to
date: <input type="text" id="datepicker">
then stops prepending text dropdown?
source code
$(document).ready(function(){ $('#datepicker').datepicker({ changemonth: true, changeyear: true, onchangemonthyear: function (year, month) { $("#startyear").val(year); $("#startmonth").val(month); } }); $(".ui-datepicker-month").prepend("<option value='' selected='selected'>month</option>"); $(".ui-datepicker-year").prepend("<option value='' selected='selected'>year</option>"); }); </script> <div id="datepicker"></div>
question: - how second demo run text box , have year , month first demo?
try solution:
$('#startdate').datepicker({ changemonth: true, changeyear: true, dateformat: 'mm yy', onclose: function (datetext, inst) { var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val(); var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val(); $(this).datepicker('setdate', new date(year, month, 1)); }, onchangemonthyear: function (year, month) { $("#startyear").val(year); $("#startmonth").val(month); } });
Comments
Post a Comment