Jump to content

Recommended Posts

Well, originally I posted this question in the PHP forum because, as you'll read, I thought it had to do with PHP. Obviously I'm not very experienced with Java or PHP otherwise I would've know where to post in the first place. Here's the whole thread so that you can follow along and understand what I'm trying to achieve. Any suggestions would be greatly appreciated. Thanks!

---start first post---

I'm not sure how to describe the effect I'm trying to achieve, so I'll point out a website that has implemented what I'd like to do:

[a href=\"http://isohunt.com/torrents.php?ihq=nature&ext=&op=and\" target=\"_blank\"]http://isohunt.com/torrents.php?ihq=nature&ext=&op=and[/a]

Notice that a 'drop down' menu appears when a title is clicked on.
How is this done? Can PHP accomplish this neat feature?
On my website I have a blog and I want readers to have the option of leaving a comment about a blog entry.
But I don't want all the comments displayed at once. At first, I only want to display the number of comments that exist for a specific blog entry. Then make that number a hyperlink that drops down the comments for that specific blog entry. Make sense?

So basically:

------------------------
| Blog entry here............|
| blah blah blah blah blah |
| blah blah blah blah blah |
| blah blah blah blah blah |
| blah blah blah blah blah |
| blah blah blah blah blah |
------------------------

There are 5 comments available. (clicking the #5 would display the comments)

--------------------------
|comment 1: blah blah blah |
--------------------------

--------------------------
|comment 2: blah blah blah |
--------------------------

--------------------------
|comment 3: blah blah blah |
--------------------------

--------------------------
|comment 4: blah blah blah |
--------------------------

--------------------------
|comment 5: blah blah blah |
--------------------------

Close Comments (this feature would make the comments disappear again)

Any help would be greatly appreciated! Thank you for your time,

*Nick*

---end first post---

---start second post---

You don't need php to do this, you need javascript/css

1. create a div that contains all your comments, give it an id or a class that you refer to in your css file

<div id='comment'>
comments go here
</div>

2. in the css, set 'display: none;' for the div that contain comments
3. create a button on your page
4. add the onclick event (javascript) to the button

<input type='button' value='show comments' onclick="document.getElementById('comment').style.display=block;">

this is all from the top of my head, I usually keep javascript language reference nearby. If you want to do some other things or just to keep things readable in your code, you could create a function that doest the same.

<input type='button' value='show comments' onclick="showcomments()">

<script type='javascript'>
var comment = document.getElementById('comment').style;
comment.display = 'block';
</script>

Warning: this will NOT create the slider effect, you need something like on [a href=\"http://script.aculo.us\" target=\"_blank\"]http://script.aculo.us[/a] for that, don't ask me questions about it, cos I just know it exists, never used it

---end second post---

---start third post---

Greetings,

Thank you for trying to help me out with this small project. I very much appreciate your ideas and time.
Unfortunately the only thing I see when I try to execute this code is the button. I'm not sure why it isn't working.

Here is my index.html page:

[code]<html>
<head>
<title></title>
<link rel="stylesheet" href="index.css" type="text/css" media="screen" />
</head>

<body>

    <div id='comment'>
        comments go here
    </div>

    <input type='button' value='show comments' onclick="document.getElementById('comment').style.display=block;">

</body>
</html>[/code]

And here is my index.css page:

[code]#comment {
  display: none;
}[/code]

Sorry, I don't know Java at all. I tried researching some things on Google, however, that lead to lots of frustration trying to troubleshoot something I don't understand. What do you think needs adjusting in this code?

Thank you for your continued help,

*Nick*

---end third post---
Link to comment
https://forums.phpfreaks.com/topic/8597-drop-down-section-for-blog-comments/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.