Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass the jquery datepicker value in form POST method?

I have a input text in the form for date and i use JQuery datepicker to select date.

 <input type="text" id="datepicker" name="datepicker" value="Date"/>

when i use form post to post the values into another php for calculation. i don't get the values from this input text alone. i get an empty value instead of selected date.

 $date=$_POST['datepicker'];

i'm not sure of how to pass the datepicker value in form POST. Can someone help me out?

like image 919
Allen Avatar asked Dec 17 '12 22:12

Allen


1 Answers

jQuery's datepicker has nothing to do with posting your form. If your form is set to "post" then whatever is left in that input field after the user has selected a date will be sent with the form.

<form action="process.php" method="post"> 
  <input type="text" id="datepicker" name="datepicker" value="Date"/>
</form>

Gives you:

$date = $_POST['datepicker'];

However if your form is being sent as a "get" request you'll need to access it as such.

<form action="process.php" method="get"> 
  <input type="text" id="datepicker" name="datepicker" value="Date"/>
</form>

Gives you:

$date = $_GET['datepicker'];
like image 104
Sinetheta Avatar answered Sep 18 '22 06:09

Sinetheta