Reputation: 3359
I would like to push JavaScript value into php:
var temp = $('#field_id').val().charAt(0);
temp returns values 1-4.
var value = "<?php echo $variable[ ..... ]['id'] ; ?>";
how to insert instead .....
Upvotes: 1
Views: 342
Reputation: 638
Its impossible, the main reason is that Php is rendered server side ( so before it arrives to the client computer), while JavaScript is rendered in the browser ( so in the client PC).
Depending from your requirement, you may use an ajax request to get the info and update the dom with javascript, or use GET or POST request with the js variable required so that PHP will have it before it renders the page.
If you wold give me more information, I may probably help you, but the question is not specific enough
Upvotes: 2