Solved

Send date to php page

Posted on 2011-03-01
10
461 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now