-4
<script>
 myjsvar= $('#project_start_date').val(); //result is 10-11-2014
</script>

<?php
  $myphpvar = //how to get value of  myjsvar into php variable?
?>

how to get value of myjsvar into php variable $myphpvar?

thanks

Devisy
  • 159
  • 3
  • 12
  • The only way would be `Ajax` or a form/link that would require a reload of the page. – Rasclatt Jan 24 '15 at 06:12
  • This should help too: [What is the difference between client-side and server-side programming?](http://stackoverflow.com/q/13840429/218196) – Felix Kling Jan 24 '15 at 06:12

1 Answers1

0

You can't use javascript variable in php code. Php code run's on the serverside and javascript code runs in the client side. You can't ask the browser to run php code.

Your variable loc will have a value only when the code reaches the browser.

If you want to get some value from server and combine it with javascript variables then do the following.

Use an ajax request and send the desired values to server. The server will return with a response. Use that response text and store it in your action variable.

Naitik
  • 1,455
  • 15
  • 26