I am trying open a calendar with datepicker on button click, and have the date go into the sibling text box when chosen. I need to be able to do this for two different text boxes.
Here is what I have so far.
I am trying open a calendar with datepicker on button click, and have the date go into the sibling text box when chosen. I need to be able to do this for two different text boxes.
Here is what I have so far.
You need to load the jQuery UI with that jsfiddle. Try the following:
<div>
<label>Start</label>
<input type="text" class="datepicker"/>
</div>
<div>
<label>End</label>
<input type="text" class="datepicker"/>
</div>
And your JS:
$(".datepicker").datepicker({
showOn: "button",
buttonImage: "link to your button here",
buttonImageOnly: true
});
Things to note: you don't need to add the button, the datepicker will do that for you - you'll need to add a link to a button image. If you don't like this then you could just remove the bottonImage reference.
All of this has been taken from the jQuery datepicker UI documentation here
EDIT: Fixed up closing tags for html elements, fixed in jsfiddle here