2013-05-29 18 views
0

此腳本用於對帖子發表評論。我無法弄清楚如何製作 - textarea name='send[mc_comment]從形式工作。帶括號的Textarea無法在jQuery中工作

當文本被添加發送[mc_comment]它的作品,但只有第一或第二個評論和其他評論是空的!

a,b,c,d,e正常工作。誰能幫我這個?

<script type="text/javascript"> 
var commentUrl = "comments.php"; 
function mainComment(a,b,c,d,e,f) { 
    var f = $("textarea[name=send[mc_comment]]").val(); 
    var page = (d); 
    $("#"+page).text("Please wait...").show(); 
    $.post(commentUrl,{user:a, friend:b, postid:c, where:d, which:e, send:f},function(data){$("#"+page).html(data).show().fadeOut(1000)}) 
} 
</script> 

表單包含:

textarea name='send[mc_comment]' 

a href='#' onclick="return false" onmousedown="javascript:mainComment('php echo $usercode; ', 'echo $othermember;', 'echo $curpost;', 'echo 'add'.$curpost;', '<echo $comment;');">Yes /a 

的comments.php從comments.php了

<?php 
$send = $_POST['send']; 
$user = $_POST['user']; 
$friend = $_POST['friend']; 
$postid = $_POST['postid']; 
$where = $_POST['where']; 
$which = $_POST['which']; 

if($which == 'comment'){ 
    print_r($_POST).'<br />'; 
    echo "a ".$user." b ".$friend." c ".$postid." d ".$where." e ".$which." f ".$send."<br />"; 
} 
?> 

的print_r顯示:

Array ([user] => 9uVrPykP5u [friend] => 9uVrPykP5u [postid] => 41 [where] => add41 [which] => comment [send] => Some text added to the form.) 

在第一篇評論這隻能。

回答

0

嘗試

$("textarea[name='send[mc_comment]']").val(); 
+0

我有10個職位,如果有意見到最後的第一個評論開始,你的代碼工作。 – user2433125

+0

對不起,我沒有完成。它只能按順序工作。如果我評論2到10,它不起作用。 – user2433125