Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PLEASE HELP

Status
Not open for further replies.

pmonza

Programmer
Aug 17, 2003
4
AR
Hi there, I need your help:
I have a function like that:

function myFunction()
{ var = "hello";
<?php
// HOW I CAN ACCEDE THE var VARIABLE FORM
// THE JS FUNCTION ????
?>
}

Thanks.

 
What is it that you want to do? Access a PHP variable in JavaScript? Or access a Javascript variable in PHP?

You can access a PHP variable in your Javascript like so:
[tt]var hello= &quot;<?php echo $hello; ?>&quot;;[/tt]

But since the JavaScript variable doesn't exist until after the server has sent the code to the browser to be interpreted, there's no way of accessing a Javascript variable in PHP without resubmitting the page.


Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
 
like dwarfthrower said u cant access a javascript variable in php. becuase php is run on the server while js is in the clients system...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top