You are saying that you are able to display the data in the textbox? Do you mean that with the use of javascript you just updated the textbox or did you actually save the data to a mendix object via the api?
Take a look at the color text box widget. This is quite small and changes a text field as well.
Probably something like:
this.connect(this.inputbox, 'onchange', dojo.hitch(this, this.changing));
// add to user interface
this.domNode.appendChild(this.inputbox);
},
changing: function () {
this.hasChanged = true;
this.onChange();
},