Thanks for the code you got me pointed in the right direction. I need to show the text that is 160 characters and under in green and the text over 160 characters in red. Below is what I have so far, it more or less works correctly but the formatting is ugly. Is it possible for the text in the textarea box to get replaced with the green/red text? Or, if not, does anyone have any ideas for making the red/green text look better, maybe forcing it to display to the right of the textarea input box?
Thanks for your help, support, knowledge and expertise.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script type="text/javascript">
<!--
function colourText(){
document.getElementById("display2").innerHTML=""
savedStr=document.getElementById("smsText").value
savedStrGREEN=savedStr.substring(0,160)
savedStrRED=savedStr.substring(160)
document.getElementById("display2").innerHTML+="<span id=display12>" + savedStrGREEN + "</span>" + "<span id=display13>" + savedStrRED + "</span>"
document.getElementById("display12").style.color="green"
document.getElementById("display13").style.color="red"
}
//-->
</script>
<style type="text/css">
textarea {
width: 500px;
height: 120px;
border: 3px solid #cccccc;
padding: 5px;
font-family: Tahoma, sans-serif;
background-image: url(bg.gif);
background-position: bottom right;
background-repeat: no-repeat;
clear:both;
font-weight:bold;
font-size:18px;
}
</style>
</head>
<body>
<br><br><br>
<div id="display2" style="float:right;margin-right:50%;margin-left:0px;margin-top:0px;font-weight:bold;font-size:18px;font-family: Tahoma, sans-serif;"></div>
<div style="margin-left:66px">
<textarea name="styled-textarea" cols="20" rows="10" id="smsText" onkeyup="colourText(id)">
</div>
</body>
</html>
Bookmarks