Results 1 to 1 of 1

Thread: Can't get Sub Element values

  1. #1
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default Can't get Sub Element values

    I'm trying to make my own comment system and have it maybe 85% of the way there but can't seem to get the inputted values to sub elements for some reason. Is the js regex operator different in some way or am I missing something else? Here's a simplified version

    Code:
    <script type="text/javascript" src="/js/jquery-1.4.2.min.js">
    </script>
    <div style="border: 1px solid #000000; margin-left:0px;">03/03/2011 11:46 AM<br />
    <a href="#" class="comment_cmd" id="hide_859">Hide Comment?</a><br />
    <p>test</p>
    <a href="#" class="comment_cmd" id="reply_859">Reply to this</a>
    	<div style="display:none;" id="reply_show859">
    		<textarea id="response_1_859"></textarea><br />
    		<a href="#" class="comment_cmd" id="replied_1_859">Reply</a>
    	</div>
    </div>
    <div style="border: 1px solid #000000; margin-left:20px;">03/02/2011 4:59 PM<br />
    <a href="#" class="comment_cmd" id="show_2225">Show Comment?</a><br />
    <p>test comment 1.1</p>
    <a href="#" class="comment_cmd" id="reply_2225">Reply to this</a>
    	<div style="display:none;" id="reply_show2225">
    		<textarea id="response_1.1_2225"></textarea><br />
    		<a href="#" class="comment_cmd" id="replied_1.1_2225">Reply</a>
    	</div>
    </div>
    <script type="text/javascript">
    var re = /reply_\d+/, shw = /show_\d+/, hde = /hide_\d+/, snd = /send_\d+/,  f_re = /replied_.*_\d+/;
    $('.comment_cmd').live('click', function() {
    	if (re.test($(this).attr('id'))) { 
    		//display reply
    		$("#" + $(this).attr('id').replace("_", "_show")).slideDown();
    		return false;
    	}
    	if (f_re.test($(this).attr('id'))) { 
    		//reply
    		var reply_id = $(this).attr('id').replace("replied", "response"), reply = $("#"+ reply_id).val();
    		alert(reply_id);
    		alert(reply);
    		return false;
    	}
    });
    </script>
    EDIT:

    So I've narrowed it down to it being the '.'s in the id that are causing this problem. Is this cause jquery thinks the id has classes associated with it? I made a work around but am still wondering about the cause. I also couldn't use and of these symbols `'!@$%^&*()=+\|.
    Last edited by bluewalrus; 03-04-2011 at 07:10 PM. Reason: Removed Link Problem, Work around found.
    Corrections to my coding/thoughts welcome.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •