JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.tinymce.com/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<select id="country" id="req">
<option value=""></option>
<option value="us">US</option>
<option value="fr">France</option>
<option value="es">Spain</option>
</select><br><br>
<textarea rows="5" cols="40" id="tinyeditor"></textarea>
<br><br>
<input type="submit" id="submit">
JavaScript
var xml = '<xmlroot><nodes><id>US</id><desc>I am in the USA Description</desc></nodes><nodes><id>FR</id><desc>I am in the French Description</desc></nodes><nodes><id>ES</id><desc>I am in the Spain Description</desc></nodes></xmlroot>';
$(function() {
tinyMCE.init({
mode:'textareas'
});
$("#country").change(function() {
loadText();
});
function loadText() {
//In this example you fetch them from the var xml. Later on you can fetch them through a get() function.
//$.get('file.xml',{}, function(xml) {
var value = $("#country option:selected").val();
$('nodes',xml).each(function() {
//Get id of selected XML node
id = $(this).find("id").text();
//Get description of selected XML node
desc = $(this).find("desc").text();
if (value != "") {
if (id.toLowerCase() == value.toLowerCase()) {
tinyMCE.activeEditor.setContent(desc);
}
}
});
//});
}
});
$("#submit").click(function() {
if($(".req").val() == "") {
$(this).next(<span style="color:red;">Required</span>)
}
})