Forum Moderators: coopster

Message Too Old, No Replies

PHP + CSS + Javascript = Confusion

Problem centers around reading/writing variables

         

Storyman

5:38 pm on Jul 31, 2004 (gmt 0)

10+ Year Member



WHAT DISPLAYS:
PHP pulls article titles and first two sentences from MySQL and displays the 6 most recent entries.

WHAT NEEDS TO HAPPEN:
When the user clicks on the article title it hides that CSS layer, then shows the CSS layer that displays the full article.

CURRENT STATUS:
Using Javascript a dummy page has been built that accomplish the show/hide feature, but two problems have been presented.

FIRST PROBLEM:
Although I understand how to use PHP to pull the six most recent article titles from MySQL what I do not understand is how to have those titles display as links that integrate with javascript.

SECOND PROBLEM:
Once the title is displayed as a link (using javascript) I am uncertain as to how to assign the PHP variable (the article ID) to the new page so it will display the article.

DO YOU HAVE ANY SUGGESTIONS?
From what I have read it seems that the problem I might be running into is how the PHP and Javascript parsers work. This point is not clear to me, regardless I would like the user to click on the article title, then display the complete article. Your suggestions and ideas are appreciated.

ergophobe

8:08 pm on Jul 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Assuming I get you right and you have a SELECT something like this

$summary = '<div class="title" id="summary_" . $row['article_id'] . '">Title and summary here <a href="#" onclick="showfull(' . $row['article_id'] . '); return true">Full article</a></div>';

$full = '<div class="full" id="article_" . $row['article_id'] . '">Title and summary here</div>';

Now set up your onclick handler using JS and whatever DOM scripting, to change from display:none to display:block and vice-versa for the divs in question.

Since you didn't ask about it, I assume you already have the onclick() handler figured out? Probably better to ask about that in the JS forum anyway if you don't, but you can also go to the quirksmode.org site to find pretty much everything you would need to know on that score.

Storyman

8:01 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



ergophobe,

Thanks for the help. Greatly appreciated.

Storyman