Forum Moderators: coopster

Message Too Old, No Replies

I need a little help finishing this........

         

someone

6:24 pm on Feb 7, 2005 (gmt 0)

10+ Year Member



I have a page like this:
-----------------------------------------

Diversity Facts

Today's fact: blah blah blah blah........

More Diversity Facts (a link)

------------------------------------------

I have a text file containing an archive of old
diversity facts, which then are parsed to the webpage
with the file() function. That part is working fine.
What I am stuck on is the link above. I want it to
make it that when people click on the "More Diversity
Facts" link, the data in the text file is parsed, then the link disappears. If people don't click on that link, it remains there for them to click on if they want. I want to do this using the same php page, I don't want it to go to another page.

Any help would be appreciated.

StupidScript

11:00 pm on Feb 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you don't want them to request a new page, then you're looking for a Javascript solution, where the page stays loaded in the browser without another request.

If you don't mind an additional request for the same page (looks like a reload):

Diversity Facts

Today's fact: blah blah blah blah........

<?php
if (!$_GET["expanded"]) {
echo '<a href="'.$_SERVER["PHP_SELF"].'?expanded=1">More Diversity Facts</a>\n';
} else {
echo 'Diversity Facts contents .....';
}
?>

This checks to see if the "expanded" parameter exists in the URI, and if it does NOT (they haven't clicked the link), then show the link. If they HAVE clicked the link, it passes the parameter to the server, and when the page is compiled by PHP, it includes the content to be displayed instead of the "more" link.

You can have multiple sections (Diversity Facts, Other Facts, etc.) by codifying the parameters, i.e. expanded_diversity, expanded_other, etc..

Hope that's helpful!