Hi All,
I’m probably missing something really silly but how to I get the date picked using JQuery’s Datepicker (UI/API/1.7.1/Datepicker - jQuery JavaScript Library ) into a variable I can use in a PHP script?
I can’t seem to figure out what to pull out of $_REGISTERS OR $_POST.
Thanks in advance.
kev.
Javascript date pickers (and other kinds of client side pickers) work by assigning the output to a field in the form that you specify. This would be a field that would be normally typed in by hand. If you do not want users to be able to change that form field by typing, then make it readonly. So the user sees that the datepicker has “filled in” the field for them when a date is clicked on.
You then process the form as normal. Nothing PHP specific either, works with any other server-side technology.
maill
June 28, 2009, 6:47pm
3
Hi kev,
here’s an example to assign the output to a field, as mentioned in the previous post,
<!DOCTYPE html>
<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#datepicker").datepicker({
onSelect: function(dateText, inst) { alert(dateText);document.getElementById('thedate').value=dateText; }
}
);
});
</script>
</head>
<body style="font-size:62.5%;">
<div type="text" id="datepicker"></div>
<form method=post>
<input type='text' id='thedate' name='thedate' />
</form>
</body>
</html>
the date chosen is in $_POST’thedate’]
HTH
Cool, thanks for your help.
kev.
user
June 30, 2009, 4:34pm
6
maill:
Hi kev,
here’s an example to assign the output to a field, as mentioned in the previous post,
<!DOCTYPE html>
<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#datepicker").datepicker({
onSelect: function(dateText, inst) { alert(dateText);document.getElementById('thedate').value=dateText; }
}
);
});
</script>
</head>
<body style="font-size:62.5%;">
<div type="text" id="datepicker"></div>
<form method=post>
<input type='text' id='thedate' name='thedate' />
</form>
</body>
</html>
the date chosen is in $_POST’thedate’]
HTH
hey there,
I did the same thing, expected that $_POST’thedate’] will return value in text box, instead it returned NULL.:\
knurpht
October 13, 2015, 11:38am
8
Hi,
Are you aware you’re reopening a 6 year old thread?