<script> CKEDITOR.instances[ckeditor_id].insertText(val); // the val will be inserted at last clicked or active cursor position in ckeditor textarea </script>