I need to set up two jQuery UI date pickers to always be displayed. I know there's an easy way to do this with DIVs, but I can't find anything on how to do it for inputs. I've tried the "show" method in the jQuery UI documentation, but that just acts as a click on the input on page load, which isn't what I'm looking for.
1 Answer
I just tested the code below and it always remains on the page. You will need to handle the selection/click events by passing options the datepicker in the javascript. I added the JS for when the user selects a date... that should give you enough to go off of.
HTML:
<div id="test"></div>
<input type="text" id="date_input">
Javascript:
$('#test').datepicker({
onSelect: function(date, obj){
$('#date_input').val(date); //Updates value of of your input
}
});
2 Comments
JacobTheDev
But that doesn't work because it doesn't populate a text input with the date. I've been forced in to using an awful WordPress plugin for a giant form, and I don't have much control over what elements appear in the form. I could write some jQuery to insert a DIV and maybe do some magic to populate the input, but I was hoping someone knew something easier.
ejc
I made an edit that should address your problem. When the user clicks on the date, it should display in the input in the HTML. Change the selector to whatever you need the date to show up on.