3

I have a textbox inside a tinymce editor. I want to change textbox text by using javascript. Can any one tell me how is this possible? Thank you

Thariama
  • 50,002
  • 13
  • 138
  • 166
  • do you solve it? I had the same problem, but I've solve it! maybe I can share my solution and see if it is what you need – chonnychu Dec 16 '20 at 01:19

2 Answers2

0

This is not difficult. First, you will need to get the body of your editor. Then you can try to find your textarea. As bios suggested it is helpfull to give an id to your textarea. Here is the necessary code

var editor = tinymce.get('your_editor_id');
$(editor.getBody()).find('textarea#your_textarea_id').innerHTML = 'my_new_text';
Thariama
  • 50,002
  • 13
  • 138
  • 166
-1

Use tinymce setContent method I hope this will help you..

// Sets the HTML contents of the activeEditor editor
tinyMCE.activeEditor.setContent('<span>some</span> html');

// Sets the raw contents of the activeEditor editor
tinyMCE.activeEditor.setContent('<span>some</span> html', {format : 'raw'});

// Sets the content of a specific editor (my_editor in this example)
tinyMCE.get('my_editor').setContent(data);

// Sets the bbcode contents of the activeEditor editor if the bbcode plugin was added
tinyMCE.activeEditor.setContent('[b]some[/b] html', {format : 'bbcode'});

please check the tinymce documentation http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent

super
  • 2,288
  • 2
  • 21
  • 23
  • This code sets the content of tinymce editor. But actually i want to change the textbox text inside a tinymce editor. i googled a lot but no use. pl help me – user1809274 Nov 14 '12 at 07:47
  • @user1809274 Use the textbox id to set the text, please check this fiddle http://jsfiddle.net/3sSVa/ this will set a text inside a textbox, i hope this will help you – super Nov 14 '12 at 08:20