View Full Version : Trying to Make an Edit in Place

12-31-2007, 09:57 PM
I am trying to make an edit in place for users to update their comments in my commenting thread script

the original comment is as such (using PHP):

echo '<span id="commBody'.$row[id].'">'.stripslashes(nl2br($commBody)).'</span>';

the edit icon is as such:

echo '<img src="img/icons/edit.gif" width="20" onClick="editComment('.$row[id].',\''.$row[commbody].'\');" alt="edit comment">';

my function are as such (the problem arises here):

function saveComment(commBodyid, newCommBody){
document.getElementById('commBody'+commBodyid).innerHTML = commBody;
// XHR code to update new comment info into database goes here
function editComment(commBodyid, commBody){
document.getElementById('commBody'+commBodyid).innerHTML = '<textarea rows="5" cols="52" style="margin:0; padding:0;" name="newCommBody" onBlur="saveComment(' + commBodyid + ', \''+ newCommBody + '\');">'+ commBody +'</textarea>';

The error I get is that var newCommBody is not defined.

When the user onBlur's the textarea, how do I save their new comment data? The current system is obviously not working. Thanks

01-04-2008, 02:43 AM

help please?