Generate an array of the $box_id's in the loop.  You can check the
cookie directly in PHP using the $_COOKIE superglobal.  After the
loop, create your script.  You can generate a JavaScript array from
your PHP array using json_encode().  Just pass that array in as the
selector for the jQuery object and you'll end up with just one line if
JavaScript.


On May 14, 5:21 pm, thekman <[EMAIL PROTECTED]> wrote:
> Hi all,
> I'm using cookies to hide some content on page load & at the moment
> the jQuery code to do this inside a php loop, so the code below gets
> executed up to 20 times.
> any ideas on how i would include this only once to hide all content
> supposed to be hidden?
>
> ...
> while (!$display->EOF and $cnt < 20) {
> other php code...
> ?>
>
> <script type="text/javascript">
>   $(document).ready(function(){
>   if ($.cookieJar('CookieJar').get('<?php echo $box_id; ?>')) {
>   $("#<?php echo $box_id; ?>").hide();}
> });
>
> </script>
>
> <?php  $display->MoveNext(); ?>

Reply via email to