I'm wondering what I'm doing wrong with my coding. The script I'm using looks up a corresponding description when a dropdown list value is selected. When the content is passed to the textarea, it displays with html which is not what I wanted. I just want the text and of course any line breaks retained. This is what I have so far. Any help would be appreciated. Thanks.
Code: Select all
<script type="text/javascript">
function showResponse(str) {
if (str=="") {
document.getElementById("txtResponse").innerText="";
return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtResponse").innerText=xmlhttp.responseText;
var text= document.getElementById("txtResponse").innerText;
var text = text.replace(/(<([^>]+)>)/ig,"");
tinymce.get('ActionTextField').execCommand('mceInsertContent',true, email); // adds the content at the carat postion
}
}
xmlhttp.open("GET","get_response.php?ResponseName="+str,true); // looks up a description based on the selection from a dropdown box.
xmlhttp.send();
}
</script>