hello,

I had a fckeditor at my php page, i want to put some data in fck editor when user click a button. How can i do that using javascript. Please help

Dani AI

Generated

Short expert summary and practical notes (keeps the thread solution but adds pitfalls and long‑term advice).

The right approach is to use FCKeditor’s JavaScript API to move content between instances (read the source editor via the API and update the target via the API). That is preferable to copying DOM values, because the editor exposes methods to get/set or insert HTML reliably. (docs-old.ckeditor.com)

Common pitfalls and what to check before you copy/append

  • The FCKeditor global API is not available until the editor finishes loading. Use the editor’s completion/event hooks rather than calling APIs on page load too early.
  • SetHTML replaces the whole editor content (and can reset listeners attached to the editor document). InsertHtml injects HTML at the current caret/selection. If you need to append at the very end, either move the caret to the end and insert, or read the target’s current HTML, concatenate, then set it back. These behaviors and the editor events are documented in the FCKeditor JS API. (docs-old.ckeditor.com)

Quick checklist before you try again

  1. Ensure both editor instances exist and are in status COMPLETE (use the API’s load/OnComplete hooks).
  2. Pull content from the source editor using the API.
  3. Decide append vs replace: use insertion at caret for in‑place appending, or get+concat+set for appending at the end.
  4. If you rely on attached editor document events, prefer an insertion approach (because SetHTML can remove listeners).
    If a long‑term fix is desired, consider migrating: FCKeditor is retired and unmaintained; CKEditor is the supported successor and uses a different API (getData/setData), so plan a migration for security and browser compatibility. (ckeditor.com)

Notes tied to this thread

  • pointed toward the API approach and ’s final post confirms the API route works.
  • If something still fails, reproduce with a minimal page (two named instances and the button handler) and confirm the editors report READY in their events before transferring content. and ’s wiring suggestions help for the button; ’s suggestion to mark solved is noted.

Recommended Answers

All 11 Replies

Check the

OnClick="MyFunction()";

and inside the function open popup with editor

function MyFunction(){
    window.open('url_to_fckeditor_file.php');
}

see for more

hello,

I had a fckeditor at my php page, i want to put some data in fck editor when user click a button. How can i do that using javascript. Please help

I dont know why dani web is not that helpful now, as it was in past. Its heppening 4th time when i am posting my problem and no one is helping me with sound solutions.

Its really very sad situation.

I have two fck editors in my web page. and i just want when user click on a button, then data will copy in fck editor-2 from fckeditor-1. I had took value of editor-1 using its object instance but i dont know how i can put that value in editor 2. I hope now you will better understand what i need.

Ok, if you can copy the values from the fields in editor 1, then this should be able to assign them to editor2.

With the onlick function that was shown, you have to get the values of the input fields in editor 1

function get() {
var input1  = document.getElementById("myinput").value
// now if its a span or input u have to use one or the other
//span
document.getElementById("myspan2").innerHTML = input1;
//input
document.getElementById("myinput2").value = input1;
}

You know, you shouldnt go roaring on the forums how much daniweb sucks and people are un responsive. That makes people not want to help you even more, because your acting like a girl. Second, you need some kind of code to help you or a really good example. People cant see your page. Third, people have lifes. Now i hope this helped.

This is not what i need. What you think i am here and i didnt try this simple code you are giving me????

This not work for fckeditor, its just work for simple input objects like text box, text area, span etc.

function getval()
{
	var Editor1 = FCKeditorAPI.GetInstance('editor1') ;
	var editor1value=Editor1.GetHTML( );
	document.getElementById("editor2").value= dueditorvalue;//assigning value to second editor - this line is not working 
}

this is the code i am using. now please help me.

Man you have PhD in complaining :scared:
why don't you use libraries like JQuery if you do alot of JS?

Have you seen typos in your code? what is dueditorvalue

function getval()
{
	var Editor1 = FCKeditorAPI.GetInstance('editor1') ;
	var editor1value=Editor1.GetHTML( );
	document.getElementById("editor2").value= editor1value ;//assigning value to second editor - this line is not working 
}

hello,

People are trying to be very helpful here.

I had a fckeditor at my php page, i want to put some data in fck editor when user click a button. How can i do that using javascript. Please help

Hi BzzBee:

I customize the FCKEditor constantly (far beyond playing in the ), however, your question is not clear enough for me to help you.
To clarify your question further?

Are you attempting to create a toolbar button to insert data into the content area?
Can you spell it out?

var Editor1 = FCKeditorAPI.GetInstance('editor1') ;
var Editor2 = FCKeditorAPI.GetInstance('editor2');
Editor2.InsertHtml( Editor1.GetHTML() );

I had resolved this issue by myself. thanks for your replies
the solution of my question is as follows for other people facing same issue.

var Editor1 = FCKeditorAPI.GetInstance('editor1') ;	
var Editor2 = FCKeditorAPI.GetInstance('editor2') ;	
var editor1value=Editor1.GetHTML( );
Editor2.SetHTML(editor1value);

Can you mark this as solved please.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.