I have little cycle. This take some image to the screen. Every image have an id which i stored in $id variable.
When user click on an image they get a popup window. Now im开发者_StackOverflow use query string. When user click, get a popup with id from query string.
But this is not a good way, 'coz if user reload the page, with the query string..they get the popup every time.
I need the $id when show the popup. How can i do this without querystring? How can i check if click on image and which image clicked on?
for j=1 .....{
...
..
for i=1....... {
$id=array[j,i];
echo "<a href=test.php><img style='z-index:$z; position:absolute; left: $lf; top: $tf;' src='images/$src' width='$width' height='$heigth' title='$title' /></a>";
}
}
You can use JavaScript to trigger the popup when the user clicks on the image. This way, nothing is sent back to the server, and there is no query string.
I don't see where you print the id for each picture to the page, but because it is psuedocode, I'll assume it works. Using javascript would look something like this:
for j=1 .....{
...
..
for i=1....... {
$id=array[j,i];
echo "<a href='javascript:alert(\"$id)\"'><img style='z-index:$z; position:absolute; left: $lf; top: $tf;' src='images/$src' width='$width' height='$heigth' title='$title' /></a>";
}
}
Clicking on the image would then generate a popup with the id of the image, and no information would be sent to the server.
you can put one function that will be incremented counter when someone click on the image. and that counter will be increment by 1 and u can also set it into database..
Try this.. thanks.
精彩评论