PDA

View Full Version : Can't get Sub Element values



bluewalrus
03-03-2011, 11:08 PM
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


<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 `'!@$%^&*()=+\|.