nick1 Posted April 27, 2006 Share Posted April 27, 2006 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* Quote Link to comment https://forums.phpfreaks.com/topic/8575-the-effect-im-trying-to-achieve/ Share on other sites More sharing options...
zq29 Posted April 27, 2006 Share Posted April 27, 2006 Looks more like JavaScript, remember - PHP is a server side language. Quote Link to comment https://forums.phpfreaks.com/topic/8575-the-effect-im-trying-to-achieve/#findComment-31434 Share on other sites More sharing options...
koencalliauw Posted April 27, 2006 Share Posted April 27, 2006 You don't need php to do this, you need javascript/css1. 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 comments3. create a button on your page4. 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 Quote Link to comment https://forums.phpfreaks.com/topic/8575-the-effect-im-trying-to-achieve/#findComment-31436 Share on other sites More sharing options...
nick1 Posted April 28, 2006 Author Share Posted April 28, 2006 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* Quote Link to comment https://forums.phpfreaks.com/topic/8575-the-effect-im-trying-to-achieve/#findComment-31508 Share on other sites More sharing options...
.josh Posted April 28, 2006 Share Posted April 28, 2006 you need to ask this question on javascript forum this is php forum not trying to be rude but you're more likely to find a good answer there. Quote Link to comment https://forums.phpfreaks.com/topic/8575-the-effect-im-trying-to-achieve/#findComment-31511 Share on other sites More sharing options...
zq29 Posted April 28, 2006 Share Posted April 28, 2006 I'll move this to our JavaScript forum. Please be aware, Java and JavaScript are two very different languages! Quote Link to comment https://forums.phpfreaks.com/topic/8575-the-effect-im-trying-to-achieve/#findComment-31586 Share on other sites More sharing options...
GBS Posted April 28, 2006 Share Posted April 28, 2006 Hi there,Try this code example,,html/javascript part is about:[code]<html><head><link rel="stylesheet" href="index.css" type="text/css" media="screen" /></head><body><script>function ShowComments(comment_id,text_id,nb){var tochange="<span class=\"comments\" onclick=\"HideComments('"+comment_id+"','"+text_id+"',"+nb+");\"";tochange=tochange+" style=\"background-color:#ECECD9;\"";tochange=tochange+" onmouseover=\"\"";tochange=tochange+" onmouseout=\"\">";tochange=tochange+"see the comment "+nb+"</span>";document.getElementById(comment_id).innerHTML=tochange;document.getElementById(text_id).style.display="block";}function HideComments(comment_id,text_id,nb){var tochange="<span class=\"comments\" onclick=\"ShowComments('"+comment_id+"','"+text_id+"',"+nb+");\"";tochange=tochange+" style=\"background-color:#CAD9EA;\"";tochange=tochange+" onmouseover=\"this.style.backgroundColor='#ECECD9';\"";tochange=tochange+" onmouseout=\"this.style.backgroundColor='#CAD9EA';\">";tochange=tochange+"see the comment "+nb+"</span>";document.getElementById(comment_id).innerHTML=tochange;document.getElementById(text_id).style.display="none";}</script><div id="comment1"><span class="comments" onmouseover="this.style.backgroundColor='#ECECD9';" onmouseout="this.style.backgroundColor='#CAD9EA';" onclick="ShowComments('comment1','text1',1);" >see the comment 1</span></div><div id="text1" class="text" style="display:none;"><table border=1 align=center width="700px"><tr><td style="background-color:#CAD9EA;">This is my first comment,...<br>hoping it's a nice one,...</td></tr></table></div><div id="comment2"><span class="comments" onmouseover="this.style.backgroundColor='#ECECD9';" onmouseout="this.style.backgroundColor='#CAD9EA';" onclick="ShowComments('comment2','text2',2);" >see the comment 2</span></div><div id="text2" class="text" style="display:none;"><table border=1 align=center width="700px"><tr><td style="background-color:#CAD9EA;">& this is my second comment,, :)</td></tr></table></div></body></html>[/code]& index.css file:[code].comments { cursor:pointer; background-color:#CAD9EA; border: 1px solid gray; width:800px; padding:0.1em;}.text { background-color:#ECECD9; border: 1px solid gray; border-top:none; width:800px; padding:0.1em;}[/code]it gives also the slider effect using onmouseout/onmouseover properties,Hoping it helps,,l8tr,, Quote Link to comment https://forums.phpfreaks.com/topic/8575-the-effect-im-trying-to-achieve/#findComment-31704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.