Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    Trying to Make an Edit in Place

    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):

    Code:
    echo '<span id="commBody'.$row[id].'">'.stripslashes(nl2br($commBody)).'</span>';
    the edit icon is as such:

    Code:
    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):

    Code:
    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

  • #2
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post
    anyone?

    help please?

    Bueller?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •