Javascript Help!!! - My New Site

Discussion in 'HTML & Website Design' started by fotc9, Jun 28, 2009.

  1. #1
    I've been at this for hours now and not the first clue why my code isn't working.

    If you check out my site at http://www.confessmyshit.com you would see people's confessions and at the bottom of each there's a link for Comments that if you click it should display the comments and a place to post your own directly under that comment. Unfortunately the code only works for the first comment on the index.php page. Here's the code I have atm:

    <a href='javascript:popComm(".$row['id'].")'>Comments (".$row['comms'].")</a>
    Code (markup):
    where $row['id'] is the confession to display comments to and $row['comms'] is how many comments are posted for each confession.

    then under the round-cornered box for each confession i have this html which is inside a php echo command (where # is the comment id to display the comments for):
    
    <div id='comments'>
    <div id='comments".$row['id']."'>
    <img src='images/tcomm.png'>
    <?php include('dispComm.php?id=".$row['id']."'); ?>
    <img src='images/bcomm.png'>
    </div><!-- comments# -->
    </div><!-- comments -->
    
    Code (markup):
    which has this css code applied to it:
    
    #comments
    {
    	display:none;
    	width:700px;
    }
    
    Code (markup):
    Then there's the javascript that should be making 'comments' and 'comments#' visible (where # is again the id of the confession to display comments for):
    
    function popComm(which)
    {
    	var area = document.getElementById('comments'+which);
    	var other = document.getElementById('comments');
    	if(area.style.display=="inline")
    	{
    		area.style.display = "none";
    		other.style.display = "none";
    	}
    	else
    	{
    		area.style.display = "inline";
    		other.style.display = "inline";
    	}
    }
    
    Code (markup):
    can anyone help me out?
     
    fotc9, Jun 28, 2009 IP
  2. fotc9

    fotc9 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hey sorry can an admin move this to programming>javascript?
     
    fotc9, Jun 28, 2009 IP
  3. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    do I need to register before I comment. When I tested it does not work for any comments not even for the first comment as you said.. by the way are using any content management system for this ?
     
    HivelocityDD, Jun 28, 2009 IP
  4. fotc9

    fotc9 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    no there's no need to register. the dispComm.php page hasn't been made yet, i'm trying to fix the popComm() part right now. the first one doesn't even work for you? Which browser are you using?

    What do you mean by content management system? confessions and comments will be stored in separate tables in a mysql database.

    i forgot to mention that the first code segment with the link to pop open comments is also in a echo, if that helps at all
     
    fotc9, Jun 28, 2009 IP
  5. fotc9

    fotc9 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    okay, nevermind i fixed it
     
    fotc9, Jun 28, 2009 IP