You probably are . . . anyway see if you can do this:
<html>
<head>
<title>Line Breaks</title>
<script langugae="javascript" type="text/javascript">
function addbr(frm)
{
val = frm.mytext.value;
val = val.replace(/\n/g,"<br>");
document.getElementById("mydiv").innerHTML = val;
newval = document.getElementById("mydiv").innerHTML;
newval = newval.replace(/<br>/gi,"<br>\n");
document.myform2.mytext2.value = newval;
}
</script>
</head>
<body>
<form name="myform" onSubmit="addbr(this); return false;">
<textarea name="mytext" cols="50" rows="8"></textarea>
<br>
<input name="submit" type="submit" value=http://www.webdeveloper.com/forum/archive/index.php/"Submit">
</form>
Live Preview:
<div id="mydiv" style="width: 420px; height: 180px; border: 1px solid; overflow: auto;"></div>
<br>
Code Generated:
<form name="myform2">
<textarea name="mytext2" cols="50" rows="8"></textarea>
</form>
</body>
</html>
=========================================
I would like for this code to work in one textarea ONLY! I am totally stumped I have been working on this problem forever and I still can't figure out how to make it happen all with one textarea. As you can see the process is done using two textareas and a div id input. I would really like to get rid of one of the textareas and the div thing so that all the above works in one textarea. Got it? I bet you do. Anyhelp, anyone
Thanks in advance
Code One
<html>
<head>
<title>Line Breaks</title>
<script langugae="javascript" type="text/javascript">
function addbr(frm)
{
val = frm.mytext.value;
val = val.replace(/\n/g,"<br>");
document.getElementById("mydiv").innerHTML = val;
newval = document.getElementById("mydiv").innerHTML;
newval = newval.replace(/<br>/gi,"<br>\n");
document.myform2.mytext2.value = newval;
}
</script>
</head>
<body>
<form name="myform" onSubmit="addbr(this); return false;">
<textarea name="mytext" cols="50" rows="8"></textarea>
<br>
<input name="submit" type="submit" value=http://www.webdeveloper.com/forum/archive/index.php/"Submit">
</form>
Live Preview:
<div id="mydiv" style="width: 420px; height: 180px; border: 1px solid; overflow: auto;"></div>
<br>
Code Generated:
<form name="myform2">
<textarea name="mytext2" cols="50" rows="8"></textarea>
</form>
</body>
</html>
=========================================
I would like for this code to work in one textarea ONLY! I am totally stumped I have been working on this problem forever and I still can't figure out how to make it happen all with one textarea. As you can see the process is done using two textareas and a div id input. I would really like to get rid of one of the textareas and the div thing so that all the above works in one textarea. Got it? I bet you do. Anyhelp, anyone
Thanks in advance
Code One