Well, I'm a noob at javascript, but I'm trying to make a script that will replace text in a textarea. Just certain text, though. Here's what I've got:
Code:
<script type="text/javascript">
function add(Ident) {
if (document.getElementById(Ident).style.background!="green") {
document.getElementById(Ident).style.background='green';
var curText = document.getElementById('locationtext').value;
document.getElementById('locationtext').value = curText + Ident + " ";
}
else {
document.getElementById(Ident).style.background='white';
locTextArea = document.getElementByID('locationtext').innerHTML;
locTextArea.innerHTML = locTextArea.replace(Ident, "DELETED");
}
}
</script>
<textarea id="locationtext"></textarea>
Shortened, I can give the whole page's code (the content), but that's the point. Right now I just want it to delete the ID found by the variable 'Ident' in the function add with 'DELETED'. But this doesn't work  .
Please help me, noob question :P
Thanks,
-PG
|