Jodarecode
07-16-2010, 08:33 PM
Here is my example code
<html>
<head>
</head>
<body onload="addtext()">
How do I keep the cursor position after the " has been replaced with &quot;?<br><br>
<form name="update" id="update" method="post" action="">
<textarea name="description" id="description" value="" cols="55" rows="15" onKeyUp="addtext()">Type a quote here[] and see the cursor move to the end here:</textarea>
<br>
Result:<br>
<div name="outputtext" id="outputtext"></div>
</form>
</body>
<script language="javascript" type="text/javascript">
function addtext() {
var newtext = document.update.description.value;
document.getElementById('outputtext').innerHTML = newtext.replace(/\r\n|\n/g,"<br />");
document.getElementById('description').value = newtext.replace(/"/g,""");
}
</script>
</html>
<html>
<head>
</head>
<body onload="addtext()">
How do I keep the cursor position after the " has been replaced with &quot;?<br><br>
<form name="update" id="update" method="post" action="">
<textarea name="description" id="description" value="" cols="55" rows="15" onKeyUp="addtext()">Type a quote here[] and see the cursor move to the end here:</textarea>
<br>
Result:<br>
<div name="outputtext" id="outputtext"></div>
</form>
</body>
<script language="javascript" type="text/javascript">
function addtext() {
var newtext = document.update.description.value;
document.getElementById('outputtext').innerHTML = newtext.replace(/\r\n|\n/g,"<br />");
document.getElementById('description').value = newtext.replace(/"/g,""");
}
</script>
</html>