Reputation: 2655
I need your help.
Is it programmatically possible to use the Jquery picker, ie. trigger the datepicker by calling a function and then store the selected date into a var as opposed to a hidden input box?
Any help with this would be greatly appreciated.
The current example that I have triggers the date picker from a function but uses a hidden input box.
<html>
<head>
<!-- LOAD JQUERY LIBRARY: -->
<link href="jq/jquery-ui.css" type="text/css" rel="stylesheet" />
<script src="jq/jquery.min.js" type="text/javascript"> </script>
<script src="jq/jquery-ui.min.js" type="text/javascript"> </script>
<script type="text/javascript">
function test() {
$("#d1").datepicker().datepicker("show");
}
</script>
</head>
<body>
<input style="display: none" type="text" id="d1">
<a href="javascript:test()">test</a>
</body>
</html>
Thanks in advance,
Cheers,
Jay
Upvotes: 0
Views: 1330
Reputation: 5543
Just attach it to a div instead of an input control.
The HTML:
<div id="d1"></div>
<a href="#" id="test">test</a>
The JS:
$('#test').click(function(){
var datePickerValue = null;
$("#d1").datepicker().datepicker("show").change(function ()
{
datePickerValue = $(this).val();
alert("You picked: " + datePickerValue);
});
});
Upvotes: 1
Reputation: 2080
I got it working in this fiddle, although it looks ugly with the hidden input box.
Upvotes: 0