2

I've got a site that I need to change the number of viewable items on the screen depending on the size of the screen. So it's a gallery that will only show as many items as will fit on the screen.

So I've got pagination set up. I can also get my javascript / jquery to determine the number of images that can be shown on each page based on the size of the screen. The problem I'm having is I don't know how to pass that information back into my PHP so that I can then change the number of results I want pulled for each page in the pagination.

My thought was to get the sizes and do all the math javascript / jquery at the very beginning then pass that data into a session variable so that it can easily be gotten and used in my queries, but I can't figure out how to get my sizes into the SESSION.

My thought was to use:

$.post('php_file_that_posts_to_session.php', { variables: 'sizes to pass'});

that didn't seem to work however. At least when i try to echo the session variable I don't get anything.

Any suggestions?

  • 11
    http://stackoverflow.com/questions/4716177/pass-a-js-variable-to-a-php-variable and http://stackoverflow.com/questions/4743842/passing-javascript-variable-to-php-session-variable and many more http://stackoverflow.com/search?q=javascript+variable+to+php – acm Jan 31 '11 at 17:23
  • @user578994, welcome to the SO community. Don't be discouraged when this question is closed. I don't know how much searching you did before asking this question, but I know that sometimes you wont find out that it's been answered until you've written the question. – zzzzBov Jan 31 '11 at 18:39
  • No worries. I searched and searched, but I don't think I really knew what I was searching for. After looking at some of the posts placed above, I got my answer and I think I got it working. Thanks a million! –  Jan 31 '11 at 18:47

1 Answers1

0

In Jquery you can use the method Data To store any info in dom element. jQuery.data()

http://api.jquery.com/jQuery.data/

"The jQuery.data() method allows us to attach data of any type to DOM elements"

jcvpacheco
  • 91
  • 4