openSUSE Forums > Programming/Scripting » JQuery DatePicker & PHP

Go Back   openSUSE Forums > Programming/Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


Programming/Scripting Questions about programming, bash scripts, perl, php, cron jobs, ruby, python, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 25-Jun-2009, 16:13
yu210148's Avatar
Explorer Penguin
 
Join Date: Jan 2009
Location: Toronto, Ontario
Posts: 154
yu210148 hasn't been rated much yet
Question JQuery DatePicker & PHP

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.
Reply With Quote
  #2 (permalink)  
Old 25-Jun-2009, 20:07
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,194
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: JQuery DatePicker & PHP

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.
Reply With Quote
  #3 (permalink)  
Old 28-Jun-2009, 11:47
Student Penguin
 
Join Date: May 2009
Location: Jakarta, Beijing
Posts: 77
maill hasn't been rated much yet
Default Re: JQuery DatePicker & PHP

Hi kev,
here's an example to assign the output to a field, as mentioned in the previous post,
Code:
<!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
__________________
"And just as you want men to do to you, you also do to them likewise."
Luke 6:31 NKJV
Reply With Quote
  #4 (permalink)  
Old 28-Jun-2009, 17:08
yu210148's Avatar
Explorer Penguin
 
Join Date: Jan 2009
Location: Toronto, Ontario
Posts: 154
yu210148 hasn't been rated much yet
Default Re: JQuery DatePicker & PHP

Cool, thanks for your help.

kev.
Reply With Quote
  #5 (permalink)  
Old 29-Jun-2009, 02:27
Student Penguin
 
Join Date: May 2009
Location: Jakarta, Beijing
Posts: 77
maill hasn't been rated much yet
Default Re: JQuery DatePicker & PHP

Glad to help
__________________
"And just as you want men to do to you, you also do to them likewise."
Luke 6:31 NKJV
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2