Solved

Send date to php page

Posted on 2011-03-01
10
458 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
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.

758 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

22 Experts available now in Live!

Get 1:1 Help Now