PDA

View Full Version : passing varible from java script to php


[m]
12-05-2002, 08:45 AM
how would I pass info from a javascript variable to a php variable

could I just be coding in php and when it comes time to define the php just put a closeing brace ?> the javascript variable then <?php and keep on coding?

the php tags woud have to go inbetween the <script language="javascript"> right?

are there any common nesting problems I might face with this?


any help you can give would be great

WA
12-05-2002, 09:04 AM
Well, the thing to first establish is that PHP is executed completely on the server end before the page even reaches the browser. With that understanding, there really is no way to pass a variable from JavaScript to PHP other than through the 3 standard ways of passing any data (not just JavaScript) to PHP:

1) Through a form, using the GET method
2) Through a form, using the POST method
3) Through a query string. ie: http://mydomain.com/?myvar=1

Now, to pass a variable from PHP to JavaScript is most certainly possible, as is passing out any arbitrary HTML, for that matter.

The two languages are completely different as far as the level in which they exist in.

[m]
12-06-2002, 06:02 AM
thanx for the reply the inforation u gave may be what I need

:)