Jump to content

Javascript output in php function parameter


orionlogic

Recommended Posts

Hi all,

 

I want some JavaScript function output in php function. Such as:

 

$my_name = "<script language=\"javascript\">document.write(\"myName\");</script>";
        echo "$my_name";
        //  Outputs :    myName

 

When i try to insert variable into some php function it gives error.

Lets say my function outputs myName and my age...

 

     $name = myName($age, $my_name); 

 

And it doesnt work. When i look into logs, i see that it gets the line "<script langua..... rather than the output.

 

 

How can i put that JavaScript string output as function parameter ?

 

Thanks a lot.

 

 

You need to use AJAX techniques for that.

 

Ken

 

 

I may try that but there is something which i dont understand.

 

The $my_name  variable holds the output as String. When i try to echo, it outputs the string like 'John' .

But when i put that variable into function it gets the script line.

 

Is that because variable is just a pointer?

 

Why not only getting the output ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.