Solved

Send date to php page

Posted on 2011-03-01
10
469 Views
Last Modified: 2012-05-11
Hi, this form send the date to alert and works fine. I will send data to a php page and put the value(date) in a variable like : $variable="date_value"
<form>
    <script>DateInput('orderdate', true, 'DD-MON-YYYY')</script>
    <input type="button" onclick="alert(this.form.orderdate.value)" value=" Send date " />
</form>
0
Comment
Question by:sam20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 14

Accepted Solution

by:
Kalpan earned 250 total points
ID: 35004844
you can use the jquery to pass to hidden variable and then use that value to submit the value....

Please refer the example

<script>
odate  = DateInput('orderdate', true, 'DD-MON-YYYY');
$(document).ready(function(){
  $("#orderdate").html(odate);
});
<script>

<form action="somepage.php"  method="post">
    <input type="hidden" id="orderdate" name="odate" value=""/>
    <input type="button" onclick="alert(this.form.orderdate.value)" value=" Send date " />
</form>


// some php page...somepage.php

<?php

echo $_POST['odate'];

?>
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35004859
0
 

Author Comment

by:sam20
ID: 35005305
Thanks all for replyes.
I've done that below as kalmax have said but nothing happens.
( I am using separate js file and have this: <head><script type="text/javascript" src="calendarDateInput.js"></script></head>

<form action="page.php"  method="post" target="main">
    <script>DateInput('orderdate', true, 'DD-MON-YYYY')</script>
    <input type="hidden" id="orderdate" name="odate" value=""/>
    <input type="button"  value="  Send date " />
 </form>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Kalpan
ID: 35005430
you would need to include

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

that will work with jquery and provide the value to hidden field...

0
 

Author Comment

by:sam20
ID: 35005561
It is still as before, nothing happens.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35005564
@sam20: did you tried what i had suggested?
0
 

Author Comment

by:sam20
ID: 35005605
Hi gruvinder,  I Will read those links that you have sujested
0
 

Author Comment

by:sam20
ID: 35005645
I am using javaScript Calender see please this script: http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm
 I will send date to a php page and put the value(date) in a variable, instead of send to alert.
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 250 total points
ID: 35005697
@sam20: i dont think it should make any difference. Just submit the hidden date field to server, and php can then read that posted data
0
 

Author Comment

by:sam20
ID: 35005768
You are right gruvinder, I got the value in this way:
<form action="page.php"  method="get" >
    <script>DateInput('orderdate', true, 'DD-MON-YYYY')</script>
    <input type="hidden" id="(this.form.orderdate.value)" name="odate" value=""/>
    <input type="submit"  value="  Send date " />
 </form>
And the page.php
<?php
echo $_GET['orderdate'];
?>

Thanks everybody
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wordpress Pagination 1 44
migrating to phpbb forum from vBulletin 4.2 3 31
Ajax and PHP 9 53
Generate PDF's using TCPDF - Initial Set Up 9 30
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question