Page 1 of 2

is there any way to make php and javascript talk?

Posted: Sat Jan 21, 2006 6:48 am
by kaos_frack
does any one have any idea how to achieve that?

Posted: Sat Jan 21, 2006 2:19 pm
by Lixas
what do you mean with your question? You mean, pull php's variables to javascript?
Maybe you could detail what you need ?

Posted: Mon Jan 23, 2006 5:09 am
by kaos_frack
yes, i mean sending a variable from one to other and call a function

Posted: Tue Jan 24, 2006 7:13 am
by Lixas
emm, it is easy. i'll shouw you simple example:

Code: Select all

<?
$message="Messages variable with content";
echo "<script language=\"javascript\" type=\"text/javascript\">";
echo "function notify(msg)" //we are creating a javascript function
echo "{alert(msg);}";
echo "notify('".$message."')";
echo "</script>";
?>
Create javascipts as you create you html page, with echo or somthing like that

or in php file for jscript you can do like

Code: Select all

window.resize(<?echo "$w, $h"?>);
and the versatile- transfer variables from javascript to php you can with $_GET or with $_COOKIE, i've never have such a problem, how to transfer from javascript to php

Simple :) good luck

Posted: Tue Jan 24, 2006 9:17 am
by kaos_frack
Lixas wrote:emm, it is easy. i'll shouw you simple example:

Code: Select all

<?
$message="Messages variable with content"]

Create javascipts as you create you html page, with echo or somthing like that

 or in php file for jscript you can do like [code]window.resize(<?echo "$w, $h"?>);
and the versatile- transfer variables from javascript to php you can with $_GET or with $_COOKIE, i've never have such a problem, how to transfer from javascript to php

Simple :) good luck
GREAT!!!
it really works
thanks

Posted: Fri Jan 27, 2006 2:10 am
by mzikawy
man u must have knowlege about the diffrent languages as " php , javascript "

to change the variables bettwen them .

Posted: Tue Feb 14, 2006 1:20 pm
by tsj5j
Its capable, but its really limited to the passing of variables.

Javascript is client-based, php is server-based, they aren't really made to co-operate.

Posted: Sat Mar 11, 2006 7:26 am
by kaos_frack
tsj5j wrote:Its capable, but its really limited to the passing of variables.

Javascript is client-based, php is server-based, they aren't really made to co-operate.
oooh, yes, i got that
javascript is interpreted by the browser
and whenever you **** any link the javascript is stopped
then the php interpreter does the job which is on the server
so whenever one of them is active the other is inactive

Posted: Sat Mar 11, 2006 11:04 am
by Lixas
ya kaos_frack, you understood right, php is server sided, js is client sided

Posted: Tue Mar 14, 2006 6:04 am
by uz
really i did not get anything
what is your aim?