Spell Checking multiple fields in one spell check

I have been exploring trying to spell check multiple fields in one go with the ability to write them back to the database as their individual component fields.
Finally, I have managed to achieve this by using a combination of the spellcheck pro and the XML plugin.
One strange issue remains in that the global field updates on screen after the spell check, but the actual value remains as the pre spell check value. So i have read this back in by select all and get selected text. ? Someone might explain this.
Nonetheless I am very pleased with the result, so i thought I would share this, as it may be useful to others producing consolidated documents from multiple fields, but who want to keep the document stored in those fields for future editing.

globals.temp=''

//Array of all database fields to spell
var spellarray=new Array('rw_ac_time','rw_ac_vehicletpe','rw_ac_position','rw_ac_protection','rw_ac_event','rw_ac_damage','rw_ac_impact')


//Loop through the fields and create a single global text field with the field by array number and its content as XML
//This is displayed in a 1X1 pixel spell element as a text_area.

for ( var i = 0 ; i < spellarray.length ; i++ )
{
globals.temp+='<'+i+'>'+forms.main[spellarray[i]]+'</'+i+'>\n'
}

//Now we can speel check this and the XML tags will be ignored as they are numbers.

var success = plugins.servoyguy_spellcheck_pro.registerSpellCheckPro(i18n.getCurrentLanguage(), false)
if(success)
{
	plugins.servoyguy_spellcheck_pro.clearElementsFromPopupSpellChecker() //clear any other elements that may have been previously added


		plugins.servoyguy_spellcheck_pro.addToSpellChecker(elements.spell, true, true)


	plugins.servoyguy_spellcheck_pro.startSpellCheck()
}
else
{
	plugins.dialogs.showErrorDialog('Spell Check Error',  'Unable to load dictionary for language: ' + i18n.getCurrentLanguage(),  'OK')
}

// One strange issue is that the global variable, although displayiong on the screen has changed,
// the actual text remains as the original string unless you physically click in the field.
// an on focus doesnt work, so i have implemented a slectall and then read that back into the field.
//Maybe someone else can comment on this, but it seems to work now.

//Make the resulting text into an XML file
elements.spell.selectAll()
globals.temp=elements.spell.getSelectedText()
globals.temp='<?xml version="1.0" encoding="UTF-8"?>\n<message>'+globals.temp+'\n</message>'


//Loop through the XML file changing the number tags back to XML tags
for ( var i = 0 ; i < spellarray.length ; i++ )
{
globals.temp=globals.temp.replace('<'+i+'>','<'+spellarray[i]+'>')
globals.temp=globals.temp.replace('</'+i+'>','</'+spellarray[i]+'>')
}
	
		
		var vXmlDoc = plugins.XML.XMLDocument(globals.temp);
	// Get the root element "message"
	var vRoot = vXmlDoc.rootElement;
	// Get children
	var vChildren = vRoot.getChildren();
	// Loop over children and get name and text
	for ( var i = 0 ; i < vChildren.length ; i ++) {
		var vChild = vChildren[i];
		var vElementName = vChild.name;
		var vElementContent = vChild.text;
	
	forms.main[vElementName]=vChild.text;
	
	
	}

David