|
Posted by Paul on 05/25/05 10:50
That's a good way to do it, as long as it works right :)
You don't have to reload... you can reload without reloading ;) but it
is quite a bit more complicated... using and dynamically created iframe
object (with Js) ... if you want to know more about that, just search
for something like iframe rpc on google...
peace
paul
Tom Scales wrote:
> It does. I ended up using cookies and it works reasonably well. I have to
> force reload the page, though, as the Javascript sets the cookies AFTER PHP
> renders the page, so the reload picks up the new cookie values.
>
> It works well. It's intended for my photography pages. The thumbnails now
> resize themselves when the window is resized. It's actually kind of cool.
>
> Tom
> "Paul" <freelance@dezignage.net> wrote in message
> news:uALke.1471779$6l.530601@pd7tw2no...
>
>>"Passing" variables from PHP to JavaScript is much easier than the other
>>way around.
>>
>>ie: echo "<script type='text/javascript'>thisPage =
>>'{$_SERVER['PHP_SELF']}';</script>";
>>
>>(very basic example).. but as soon as you're trying to pass variables
>>from JavaScript to PHP it gets quite a bit more complicated. As far as I
>>know, you will not be able to do it in any other way other than submitting
>>the page with a form (hidden fields and what not) .. or through the URL ..
>>(which can reveal data).
>>I would say the easiest and best way is to create a form with hidden
>>values that javascript sets... and the only way to get to the second page
>>(where you need php to get your Js vars) is through javascript form
>>submission.... so any link that's on the page would call a js function for
>>instance loadPage(url) and that function would verify you have the data
>>you need and then submit the form... (form's action attribute ofcourse
>>would be the url to your second page.)
>>
>>I hope this makes sense to you :)
>>
>>take care,
>>
>>Paul
>>
>>Tom Scales wrote:
>>
>>>I need a set of variables that I can access in both PHP and in
>>>Javascript. There are just a few things I can do in one that I cannot do
>>>in the other.
>>>
>>>I've tried:
>>>
>>>- URL parameters (i.e. ?a=a&b=b)
>>>
>>>This works, in fact very well in php, but poorly in Javascript which has
>>>no facility to split them. Also, I have more variables than I would like
>>>to pass in the URL
>>>
>>>- Hidden form fields (as described in a recent post)
>>>
>>>Contrary to the implication of the post, then don't seem to cross pages.
>>>For example, if page 1 has an <a href> to page 2, page 2 is unaware of
>>>the hidden form fields on page 1
>>>
>>>Any better suggestions? I'm leaning towards cookies, as both handle them
>>>reasonably well, but many people turn off cookies.
>>>
>>>Thanks,
>>>
>>>Tom
>
>
>
[Back to original message]
|