Hello everyone,
Please help me, I begginer and can't solve one question.
How can I get variable from javascript environment and use for php variable?
Beforehand thankfull,
Ruzanna
How to get variable from javascript env. and use for PHP?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
...
Or, is this what you meant:
NOTE - JavaScript_variable first needs to be declared inside the JavaScript so you could "write it" inside the php.
like this:
fill the
form_name = with the name of your form
and
field_name = with the field you want to pass
NOTE - this is the code only if the JavaScript and PHP are on the same page.
Hope this helps.
Code: Select all
<?php
$variable = "<script language"javascript">document.write(JavaScript_variable);</script>";
...
?>like this:
Code: Select all
<script language"javascript">
JavaScript_variable = document.form_name.field_name.value
</script>form_name = with the name of your form
and
field_name = with the field you want to pass
NOTE - this is the code only if the JavaScript and PHP are on the same page.
Hope this helps.
Basically, yes - but the lines are blurring:twigletmac wrote:PHP could only access the variable if you refreshed the page and passed it via POST (e.g. a form), via GET (ie. in the URL) or in a cookie.
Mac
http://www.sitepoint.com/blog-post-view.php?id=191776
http://www.sitepoint.com/blog-post-view.php?id=192138
http://www.sitepoint.com/blog-post-view.php?id=193677
like I still don't have enough to figure out with XML now you have to go and throw this into the works. Thanks patrickG.
I been using the IFRAME method for a while and it does work providing you are willing to do lots of coding in JS. It is fairly straigth forward but referencing around the different windows can get tiresome.
I been using the IFRAME method for a while and it does work providing you are willing to do lots of coding in JS. It is fairly straigth forward but referencing around the different windows can get tiresome.