AJAX Show/hide text

monktus

Registered
I've been looking for a script that I assumed would be easy enough to find but I haven't had any luck yet. If anyone knows of a script, or even some pointers for writing one I'd appreciate it.

I have an RSS feed on a web page that has blog entries (title and preview/description) displayed with Magpie. What I'd like to do is have a "Read more..." link at the end of each post desc that will show the whole post.

There's a PHP loop that echoes variables holding the title and description for each post, however I can also include one for the post body.

Code:
<?php 

$rss = fetch_rss("http://blog.myspace.com/blog/rss.cfm?friendID=18871906"); 

'title']."</B></a>";
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];
$desc = $item['description'];
echo "<P><a href=$href>$title</a><BR>";
if($desc)
echo $desc;
}
?>

I've been thinking that the two obvious ways to do it are:

1) Swapping the $desc variable for $body (or whatever) when the link is clicked
2) Loading the body variable and truncating the text, then displaying it all when the link is clicked

I'm assuming that JavaScript is the way to go with this but any suggestions would be appreciated. Thanks.
 
Back
Top