I am making a comments system and each comments textarea gets a unique class.
My code-
$(".ccoomm").click(function() {
var pid = $(this).attr("id");
var tt = $("textarea ."+pid).val();
var email = $("#hidden").val();
var data = "pid=" + pid + "&text=" + tt + "&email=" + email;
$("#flash").show();
$("#flash").fadeIn(500).html('<img src="wamp.gif" /> Loading...');
$.ajax({
type: "POST",
url: "comments.php",
data: data,
cache: false,
success: function(html) {
$(".coments"+pid).append(html);
$("#flash").fadeOut(100);
$("#tt").val("");
$(".comments"+pid).slideToggle(100);
$(this).toggleClass("active");
}
});
});
I am unable to get the textarea value…. It says “undefined”
The html/php-
echo <li><textarea cols='20' rows='1' class='tt' id='".$comid."' placeholder='Comment..'/></textarea><input type='submit' value='Comment' id='ccoomm' class='".$comid."' /></li>";
echo "</ul>";
Not sure but are you expecting to add an
idaftertextareain your value selection?Right now, it looks like you are selecting a
class.If you want the
idchange the second line toEDIT
Looking at the HTML you supplied in the edit, you could change the line to