Jump to content

Passing javascript variables to PHP


JustinM01

Recommended Posts

OK, I have a PHP calendar function that displays all the posts for the current year (when the page loads). I have arrows that allow the user to change which year to display. I'm trying to use AJAX so the page wouldn't have to be reloaded. I have it setup like this:

 

Calendar page -> Javascript js file -> PHP handling script

 

The handling script creates a new calendar object and initializes it to the requested year. The problem is that the two objects are not referencing the same object, so a user can only decrease the calendar date to 2006 or increase it to 2008 because every time the original page loads the calendar initializes to 2007. I don't have a problem passing variables from the original page through javascript and to the handling php script, but I do in the reverse direction. I currently call the javascript function from an onClick event in a link.

 

Is there something I'm not seeing, or will the way I'm currently doing it not work and is there another way I should look at?  ???

 

Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.