Page 1 of 1

CSS Div send vars to PHP function

Posted: Thu Apr 22, 2010 7:40 pm
by sleepydad
I am using a CSS popup which calls in a PHP page using include(). The contents of the page being called in are dynamically generated based on a variable which I've named '$id'.

Code: Select all

<?PHP
function callPage($id) {
include("page.html?id=".$id);
}

echo "<a onmouseover='this.style.cursor=\"pointer\" ' onfocus='this.blur();' onclick=\" document.getElementById('PopUp').style.display = 'block'\" ><span style=\"text-decoration: none;\">".$row['title']."</span></a><br>";

$id=xx;
callPage($id)

///// MORE CSS
?>
Somehow I need the onclick handler to get the value of $id from my CSS statement to the the variable $id to be used in the function callPage(). Variable $id will come from a database using $row['id'].

Three days working on this on my own and no solution. I'm beginning to think this may be impossible. Anyone have any suggestions?

Thanks!

Re: CSS Div send vars to PHP function

Posted: Wed May 19, 2010 9:19 am
by katierosy
Add the ID to the HTML element, which need to clicked to get the popup. Use jQuery (http://api.jquery.com/event.target/) to get the clicked ID from the HTML element and store it in a variable. then pass the value to PHP function and get the desired output.