0

I have a form that when the person selects the date I want the value to go into a php function. I can view the value by using this.form.orderdate.value, but I want to put that value into the php variable $dateChosen

Here is the page so far:

TDM KML Generator

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <script type="text/javascript">DateInput('orderdate', true, 'YYMMDD')</script>
    <input name="submit" type="submit" value="get KML" />

</form>
</body>

1 Answer 1

1

Javascript is all executing on the client machine, with the exception of an ajax call (which is still browser/client side and is making a request to a server-side function). PHP happens all server-side. In your case, you're trying to do something that isn't possible, because the PHP script is no longer executing by the time the page is rendered in the browser and the javascript is able to execute.

3
  • But wouldnt it be possible to do once the page reloads when the form is submitted?
    – shinjuo
    Commented Feb 10, 2011 at 20:53
  • I mean you can use a form and add values all day long then use them in a php script. Does it not work the same with the javascript?
    – shinjuo
    Commented Feb 10, 2011 at 20:54
  • In that case you'd be submitting the form and not need the javascript to place the value. If you're talking about adding more form fields that don't exist yet to the page that are submitted, then you'll need to either manipulate the DOM or use a JS library to manipulate forms.
    – dmcnelis
    Commented Feb 10, 2011 at 20:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.