Jump to content

jquery help


RalphLeMouf

Recommended Posts

I have a social network that has custom made comments section for users. Users are also able to reply to comments. Each comment has a 'reply' button that when pressed, uses jquery to make a new text box structure appear.

 

It is a bit lengthy in syntax and logic so I am a bit lost on what the problem may be ( it is not functioning at all. I have also run out of trouble shoot methods.

 

Here is the code for the comments and replies:

 

<div id="x_comment_box">
                <form name="x_comment_form" method="post" action="Project-X.php">
                    <textarea name="comment_body" class="round_10px defaulted">Leave a comment about "Name of Video"...</textarea>
                    <input type="submit" name="x_submit" value="Submit" class="post"/>
                </form>
            </div>
            <?php   
            $query = "SELECT * FROM `x_comments` WHERE `status` = 'active' ORDER BY `date` DESC, `time` DESC LIMIT 10";
            $request = mysql_query($query,$connection) or die(mysql_error());
            while($result = mysql_fetch_array($request)) {
            $webcast_poster = new User($result['userID']);
            $body = $result['commentBody'];
            $date = $result['date'];
            $time = $result['time'];
            $comment_id = $result['id'];
            ?>

                <div class="comment_structure_future_webcast_x clearfix">
                    <a name="comment_<?php echo $result['id']; ?>"></a>
                    <div class='comment_polaroid_future'>
                        <a href='http://www.cysticlife.org/Profile.php?id=<?php echo $poster->id ?>'>
                            <img src='<?php echo $webcast_poster->img('mini'); ?>' border='0'/>
                        </a>
                    </div>
                    <div class='comment_body_future_webcast_x round_10px'>
                        <div id='CommentNameProfile'>
                                <a href='http://www.cysticlife.org/Profile.php?id=<?php echo $auth->id; ?>'>
                                    <?php echo $webcast_poster->first_name. " ". $webcast_poster->last_name; ?> says...
                                </a>
                        </div>
                        <?php echo strip_tags(stripslashes(nl2br($result['commentBody'])),'<br><br />'); ?>

                        <div id='CommentInfoProfile'>
                            <?php echo date('M d, Y',strtotime($result['date'])); ?> at <?php echo date('g:i A',strtotime($result['time'])); ?> • 
                            <?php if($webcast_poster->id == $auth->id) { ?>
                                <a href='#' onclick='confirmation("DeleteWebcastComment.php?id=<?php echo $result['id']; ?>&ret=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>");'>Delete •</a> 
                            <?php } ?>
                            <a href='#reply_form_<?php echo $result['id']; ?>' name='reply_to_<?php echo $result['id']; ?>' class='reply_link'>Reply</a>
                        </div>
                    </div>
                    <div class='profile_comment_tail_future'> </div>

                </div>
            <?php }?>
                <?php
                /* responses */ 
                $query = "SELECT 
                                * 
                            FROM 
                                `x_comments_replies` 
                            WHERE 
                                `commentID` = '" . $result['id'] . "' 
                                && `status` = 'active' 
                                ORDER BY `date` ASC, `time` ASC";
                $request2 = mysql_query($query,$connection);
                while($reply = mysql_fetch_array($request2)) { 
                $replier = new User($reply['replierID']);
                ?>

                <div class="response_structure_future">
                    <a name="response_<?php echo $reply['id']; ?>"></a>
                    <div class="response_polaroid_future">
                        <a href="http://www.cysticlife.org/Profile.php?id=<?php echo $replier->id; ?>">
                        <img src="<?php echo $replier->img('mini'); ?>" /> 
                        </a>
                    </div>

                    <div class="response_body_future round_10px">
                        <div class="response_arrow_future"></div>
                        <div class="response_tail_future"></div>
                        <div class="response_data_future">
                            <div class="response_name_future">
                                <a href="http://www.cysticlife.org/Profile.php?id=<?php echo $replier->id; ?>">
                                <?php echo $replier->first_name . " " . $replier->last_name; ?> says...
                                </a>
                            </div>
                            <?php echo strip_tags(stripslashes(nl2br($reply['comment'])),'<br><br />'); ?>
                            <div class="response_info_future">
                                <?php echo date('M d, Y',strtotime($reply['date'])); ?> at <?php echo date('g:i A',strtotime($reply['time'])); ?>
                                <?php if($auth->id == $replier->id || $auth->id == $result['ToUserID']) { ?>
                                <a onclick="confirmation('DeleteAirwaveReply.php?id=<?php echo $reply['id']; ?>&ret=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>');"> • delete</a>
                                <?php } ?>
                                <div id="thumb_holder_replies">
                                    <div id="thumb_report_replies">
                                        <a href="mailto:info@cysticlife.org">
                                            report
                                        </a>
                                    </div>
                                    <div  class= "thumb_counter_replies" id="thumb_counter_replies_<?php echo $reply['id']; ?>">
                                    +<?php echo $reply['thumbsUp_reply']; ?>
                                    </div>
                                    <div id="thumb_thumb_replies">

                                        <?php $comment_reply_id = $reply['id'];?>
                                    <a class="myButtonLink" href="Profile_test.php?id=<?php echo $prof->id; ?>" id="<?php echo $comment_reply_id; ?>">Vote Up!</a>

<?php echo $replier->id; ?>
<?php print_r($replier->id); ?>
<?php echo $result['id']; ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <?php } ?>

                <a name='reply_form_<?php echo $result['id']; ?>' style="clear:both"></a>
                <div id='reply_to_<?php echo $result['id']; ?>' class="respond_structure_future" <?php if(isset($_GET['reply_to']) && $_GET['reply_to'] == $result['id']) { echo 'style="display:block;"';}else{ echo 'style="display:none;"';} ?>>
                    <div class="respond_polaroid_future">
                        <a href="http://www.cysticlife.org/Profile.php?id=<?php echo $auth->id; ?>">
                            <img src="<?php echo $auth->img('mini'); ?>" />
                        </a>
                    </div>                              
                    <form name='comment_reply' action='<?php echo $_SERVER['REQUEST_URI']; ?>' method='post'>
                        <div class="respond_body_future round_10px">
                            <div class="respond_arrow_future"></div>
                            <div class="respond_tail_future"></div>
                            <div class="respond_data_future">
                                <textarea id="reply_to_<?php echo $result['id']; ?>_textarea" name='reply'></textarea><br />
                                <input type='hidden' name='comment' value='<?php echo $result['id']; ?>' />
                                <div class="respond_nevermind">
                                    <a href="reply_to_<?php echo $result['id']; ?>">nevermind</a>
                                </div>
                                <input type='submit' class="submit" name='sub_comment_reply' value='Reply' />
                            </div>
                        </div>
                    </form>
                </div>
Here is the jquery:

<script type="text/javascript">
$(document).ready( function() {
    $('#Comments').localScroll({ offset:{top:-40,left:0} });
    $("a.reply_link").click( function() {
        $("#"+$(this).attr('name')).fadeIn('slow');
    });

    $(".respond_nevermind a").click( function(event) {
        event.preventDefault();
        var reply_box = document.getElementById($(this).attr('href'));
        $(reply_box).css('display','none');

        var reply_textarea = document.getElementById($(this).attr('href')+"_textarea");
        $(reply_textarea).val('');
    });
});
</script>
thanks in advance

Link to comment
Share on other sites

not working at all
is a pretty generic description. Maybe do some error reporting and tell us if you get any errors.

 

place this above your script:

 

error_reporting(E_ALL);
ini_set("display_errors", 1);

 

besides that are you including the classes used like "User()"

Link to comment
Share on other sites

how is that generic? it has all the code and clearly explains the problem.

Because everyone comes here for stuff that "doesn't function".

 

What happens? 

What doesn't happen? 

Is there a blank screen?

Did you turn on error reporting aforementioned by cssfreakie? 

What have you done to trouble shoot? 

Have you tried to isolate a general part of code that's causing the trouble?

Why are you so sure it's a JQuery issue?

Link to comment
Share on other sites

There is no further way to explain the fact that there is supposed to be a new text box that scrolls open via jquery when the 'reply' button is hit. if you want an example of how it works. Go to http//:www.cysticlife.org and sign in with the email: michael@thewizkids.net and pw: 1234 Once your in go to a profile and hit reply on one of the user generated comments and you'll see how it's supposed to work. On this new page I am doing I can not get it to do that function.

 

As far as trouble shooting, I have tried different script tags in the header and changed my all of my correlating div naming schemes. compared to all the pages that have worked. copy and pasted it from the working pages and tried to adapt it to the relavent page. Is there anything else you need besides that?

 

thanks for helping

Link to comment
Share on other sites

Ok it should be fixed.

 

username: michael@thewizkids.net

 

password: 12341234

Ok, it works now & I see what you mean.  Before I dive into your code, have you tried enabling Firebug and making sure there were no fatal errors?  If there are, JS won't do anything.

Link to comment
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.