Great. I will try it out. Thank you for the correction. I am new to web
development.
On Oct 22, 12:05 am, "Brian Peiris" <[EMAIL PROTECTED]> wrote:
> Hello John.
> The following code should do what you want.
> Note the *style="display:none;"* added to the description div. This
> hides the div in the beginning
> I tidied up the PHP a bit, I hope you don't mind.
> Using the alternative, foreach(...): ... endforeach; syntax, saves a
> lot of echoing and sprintf's and just makes things look better and
> easier to maintain. Also <?=$someVariable?> is short for <?php
> echo($someVariable); ?>
>
> <ul>
> <?php foreach ($query->result() as $card): ?>
> <li>
> <a
> href ="#"
> onClick="Effect.toggle('card-view-slide_<?=$card->idCard?>',
> 'slide'); return false;">
> <?=$card->cardName?>
> </a>
> </li>
> <div
> id="card-view-slide_<?=$card->idCard?>"
> style="display:none;"><div>
> Description/Stats of <?=$card->cardName?>
> </div></div>
> <?php endforeach; ?>
> </ul>
>
> - Brian Peiris
>
> On 10/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi guys,
>
> > I just started on AJAX and Scriptaculous/Prototype is looking great.
>
> > I have a problem integrating PHP with it.I generate this HTML page
> > based $query. It display a list of items: its name and its description
> > (currently using a placeholder for description).
>
> > Each item uses Effect.toggle(slide) to slide the description in and out
> > of the page when a user click on the item name.
>
> > How do I make the descriptions "hide" the first time I run the page?
> > i.e. don't show the <div> section at the start, only show it when a
> > user click on an Item Name.
>
> > Thanks for your help.
>
> > P/S: I am developing a Trading Card Game with Flash/AJAX/PHP with a
> > team.
>
> > The following is my code snippet:
> > -------------------------------------------------------
> > <?php
> > echo "<ul>\n";
> > foreach ($query->result() as $card) {
> > $a_out = sprintf("<li><a href ='#'
> > onClick=\"Effect.toggle('card-view-slide_%s',
> > 'slide'); return
> > false\">%s</a></li>\n",
> > $card->idCard, $card->cardName);
>
> > $div_out = sprintf("<div
> > id=\"card-view-slide_%s\"><div>Description/Stats of %s</div></div>",
> > $card->idCard, $card->cardName);
>
> > echo $a_out;
> > echo $div_out;
> > }
> > echo "</ul>\n";
> > ?>--
> ============================
> Brian Peiris
> Waterloo, Ontario, Canada
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> ============================
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---