Solved

Send date to php page

Posted on 2011-03-01
10
474 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

691 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