Hi all,
Just wondering if it is possible to do the following, and if so any hints on how to go about it would be appreciated.
Im developing a photogallery which is part of a cms.
I use php to retrieve the image name from a db after its been uploaded.
rather than refresh the entire page, I want the gallery to display in the manner of a site I worked on some time ago using javascript
http://www.colourcosmetica.com/gallery/2004expo.html#
anyway I call the javascript function no worries from inside php using onclick but the variable never seems to be passed.
Is this possible to do or do I need start taking Ajax tutes to get the result I want (groan)
thanks in advance
cheers!
Passing a Variable from php -> Javascript function
Moderator: General Moderators
-
JediEnigma
- Forum Newbie
- Posts: 1
- Joined: Tue Aug 07, 2007 11:19 pm
Re: Passing a Variable from php -> Javascript function
No you don't. onclick is a client-side event (handler). php runs on the server. Only the output of the php script is sent to the client. The client doesn't see php, it only sees e.g. the html code containg a javascript event handler. When the user clicks on the element with the onclick handler the php instance probably has already been discarded by the server.JediEnigma wrote:anyway I call the javascript function no worries from inside php using onclick but the variable never seems to be passed.
If you want to exchange data between the client and the server again you have to perform a new http request. With ajax you can do that.JediEnigma wrote:Is this possible to do or do I need start taking Ajax tutes to get the result I want (groan)