tags:

views:

31

answers:

1

I'm using nicEdit but it doesn't play well with our CMS. I need to take the formatted content that is generated by nicEdit and copy it to the appropriate text area field. Here is what I have.

<div contenteditable="true" style="width: 542px; margin: 4px; min-height: 120px; overflow: hidden;" class=" nicEdit-main   "><span _moz_dirty="" style="color: rgb(153, 153, 0);">fdsfdsfdsfdsfdsfds</span><br></div>

I need to take the html inside the div and copy it here:

<textarea style="width: 550px; class="cat_listbox" rows="10" cols="50" id="ItemDescription" name="ItemDescription"></textarea>

The content needs to go inside the text area tag in order to be submitted to the database. The event could be on submit or it could be dynamic. Either way would be good.

Any help would be appreciated.

A: 

It'll help if you can identify your DIV with an ID (I've assumed "editorContent" below). You want to add a function to the click event of your submit button that grabs the HTML inside the editorContent element (DIV) and then sets the value of the text area to that value.

​$('#submit').click(function(){
  var htmlContent = $('#editorContent').html();
  $('#ItemDescription').val(htmlContent);
});​​​​​
Bernhard Hofmann
Barnhard, this worked perfectly. Thanks!
mmsa
I'm glad I could help, not only on this question, but to help you improve your acceptance rate - it will make a big difference to some people.
Bernhard Hofmann