Question: I've added a CKEditor instance programmatically to my page in the code-behind of my ASP.NET page:

VB.NET:

```
itemEditor = New CkEditor
cell.Controls.Add(itemEditor)

```

... which works fine. I can get the HTML on the postback and do stuff with it.

However, I also want to do some client-side stuff with it, specifically take a selected item out of another control, and insert it into the text by handling the `onchange` event.

So, how can I get the name of the editor instance in the JavaScript, so that I can do stuff like:

```
function GetCkText()
{
    var htmlFromEditor = CKEDITOR.instances['editorName'].getData();
    // do stuff with htmlFromEditor
}

```

Answer: 
Assuming you only have one editor instance:

```
for ( var i in CKEDITOR.instances ){
   var currentInstance = i;
   break;
}
var oEditor   = CKEDITOR.instances[currentInstance];

```

Here is what the JavaScript API says about [instances](http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html#.instances).

Here is another way of defining the CKEditor. Here 'fck' is the input fields id:

```
CKEDITOR.replace( 'fck', {
    customConfig : prefix + 'js/ckeditor/config.js',
    height: 600,
    width: 950
});

editor = CKEDITOR.instances.fck;

```

Notice how I am then able to reference the instance using `.fck`.
If you are using `CKEDITOR.appendTo(...)`, keep in mind that the ckeditor does create an instance name internally. So you can query for that name immediately after creating it, then store it somewhere, and use it later.

```
var lvo_editor = CKEDITOR.appendTo( "my_div" , null , lvs_html ) ; 
my_global_var  = lvo_editor.name                                 ;

```

by the way: The `CKEDITOR.replace(...)` method allows you to define an instance name (see answer above)