Connecting Tech Pros Worldwide Forums | Help | Site Map

HELP: returned php value as a javascript function parameter

Newbie
 
Join Date: Jan 2008
Posts: 1
#1: Jan 7 '08
Hello Friends,

I'm working on a project which involves JavaScript and PHP and I'm really stuck.

I have a php file which returns a string (myPHPfile.php)

I would like to use this string as a parameter in one of my javascript function (myFunction(string)).

Expand|Select|Wrap|Line Numbers
  1. <body onload="load(); myFunction(myPHPfile.php);" >
But I don't know how to run myPHPfile within the code and recieve the value so that myFunction would run later.

Or perhaps I'm looking for a general answer of how to capture a value from PHP and use it in a JavaScript function as a parameter.

Thank you in advance.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Jan 7 '08

re: HELP: returned php value as a javascript function parameter


Quote:

Originally Posted by nomadturk

Hello Friends,

I'm working on a project which involves JavaScript and PHP and I'm really stuck.

I have a php file which returns a string (myPHPfile.php)

I would like to use this string as a parameter in one of my javascript function (myFunction(string)).

Expand|Select|Wrap|Line Numbers
  1. <body onload="load(); myFunction(myPHPfile.php);" >
But I don't know how to run myPHPfile within the code and recieve the value so that myFunction would run later.

Or perhaps I'm looking for a general answer of how to capture a value from PHP and use it in a JavaScript function as a parameter.

Thank you in advance.

Javascript runs on the client side while PHP runs on the server. To get a PHP result to your Javascript function you can use AJAX.
Reply