How would I go about pulling ‘&something=’ if there is no static value to pull? How would combine ‘commentBox’ and var id if that is a possible solution?
// process addComment()
jQuery(".textbox1").keydown(function(event) {
var keyCode = event.keyCode || event.which;
if (keyCode === 13) {
addComment(this);
}
});
function addComment() {
var id = jQuery(e).attr("id");
var newId = id.replace("commentBox-", "");
var dataString = '&something=' + newId;
// proceed with ajax call
}
Pass the current object (the textbox where the enter key was pressed) to the addComment function.
JsFiddle Sample http://jsfiddle.net/YAQpc/8/