killervastu Posted November 12, 2011 Share Posted November 12, 2011 Hey guys, I want to pass the unique id of a node to a function when that image is clicked. Actually i am a newbee in php so don't know what to search about or where to look for it,but find this place and you all guys so helpful so i am asking for a guide here :-\ Quote Link to comment https://forums.phpfreaks.com/topic/251031-passing-variables-to-a-function-on-a-click-on-image/ Share on other sites More sharing options...
trq Posted November 12, 2011 Share Posted November 12, 2011 You would need to create a link that requests your php script. eg; <a href="/yourscript.php?id=10"><img src="foo.png" /></a> Then in yourscript.php the id will be within $_GET['id']. Quote Link to comment https://forums.phpfreaks.com/topic/251031-passing-variables-to-a-function-on-a-click-on-image/#findComment-1287708 Share on other sites More sharing options...
killervastu Posted November 13, 2011 Author Share Posted November 13, 2011 Thanks for reply but, will it work if it should have to load the same page i want to display 3 levels of a binary tree now if i click on the last node then the last node should take the position of the source node and should act like it i.e. display all the nodes below the clicked node up-to 3 levels again. Quote Link to comment https://forums.phpfreaks.com/topic/251031-passing-variables-to-a-function-on-a-click-on-image/#findComment-1287714 Share on other sites More sharing options...
trq Posted November 13, 2011 Share Posted November 13, 2011 will it work if it should have to load the same page Yes. Quote Link to comment https://forums.phpfreaks.com/topic/251031-passing-variables-to-a-function-on-a-click-on-image/#findComment-1287716 Share on other sites More sharing options...
killervastu Posted November 13, 2011 Author Share Posted November 13, 2011 suppose if i am passing for the first time in source node the $_session['id'] then how will i change the value passed in the function on clicking will this work function ($var = $_session['id']) { code } Quote Link to comment https://forums.phpfreaks.com/topic/251031-passing-variables-to-a-function-on-a-click-on-image/#findComment-1287718 Share on other sites More sharing options...
killervastu Posted November 13, 2011 Author Share Posted November 13, 2011 sorry appending the above, if($var != '') { function($var); } else { function($var= $_session['id']) } Quote Link to comment https://forums.phpfreaks.com/topic/251031-passing-variables-to-a-function-on-a-click-on-image/#findComment-1287719 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.