Thank you Alexandra for your reply on how to get the editor to update a form element. I developed a small mod to the original dhtmlxeditor.js script so the editor will have a .BoundControl property and will be easy to implement in a parent document. You are welcome to take these and roll them into the editor in a future version if you so desire. Here are mods required:
These are based off the v.2.5 build 91111 of dhtmlxeditor.js script.
Around line 70:
this.edDoc = this.edWin.document;
this._prepareContent = function(saveContent) {
Change to
this.edDoc = this.edWin.document;
//%%%###%%%
// Added 2/8/2010 - MKA - Adds ability to set a bound text based control to the editor
// and have it updated as the editor is used
this.BoundControl = null;
this._updateBoundControl = function() {
if (this.BoundControl){
try { this.BoundControl.value = this.getContent(); } catch(e){};
}
}
//%%%###%%%
this._prepareContent = function(saveContent) {
Around Line 159:
this.runCommand = function(name,param){
if(arguments.length < 2) param = null;
if(_isIE)this.edWin.focus();
this.edDoc.execCommand(name,false,param);
if(_isIE){
this.edWin.focus();
var self = this;
window.setTimeout(function(){
self.edWin.focus();
},1);
}
}
Change to:
this.runCommand = function(name,param){
if(arguments.length < 2) param = null;
if(_isIE)this.edWin.focus();
this.edDoc.execCommand(name,false,param);
if(_isIE){
this.edWin.focus();
var self = this;
window.setTimeout(function(){
self.edWin.focus();
},1);
}
//%%%###%%%
that._updateBoundControl();
//%%%###%%%
}
Around Line 200:
if((key==37)||(key==38)||(key==39)||(key==40)||(key==13))
that.showInfo(el);
});
Change to:
if((key==37)||(key==38)||(key==39)||(key==40)||(key==13))
that.showInfo(el);
//%%%###%%%
that._updateBoundControl();
//%%%###%%%
});
Arround Line 341:
this.setContent = function(str){
if(this.edDoc.body){
this.edDoc.body.innerHTML = str;
this.callEvent("onContentSet",[]);
if(_isFF){ this.runCommand('InsertHTML',' ');}
}
else{
var that = this;
dhtmlxEvent(this.edWin, "load", function(e){
that.setContent(str);
})
}
}
Change to:
this.setContent = function(str){
if(this.edDoc.body){
this.edDoc.body.innerHTML = str;
this.callEvent("onContentSet",[]);
if(_isFF){ this.runCommand('InsertHTML',' ');}
}
else{
var that = this;
dhtmlxEvent(this.edWin, "load", function(e){
that.setContent(str);
})
}
//%%%###%%%
that._updateBoundControl();
//%%%###%%%
}
To use in your document:
dhtmlx.image_path = "/shared_js/dhtmlxSuite2/dhtmlxEditor/codebase/imgs/";
editor = new dhtmlXEditor("EditorDIV", "dhx_skyblue");
editor.init();
editor.BoundControl = document.getElementById("MyTextBox");
The above assumes EditorDIV is the DIV layer for the editor and MyTextBox is a form control such as an INPUT text type, TEXTAREA or a INPUT hidden. The bound control can be anything with a .value so even a checkbox or radio button would work but my intention is to use it with a TEXTAREA.