• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 805
  • Last Modified:

Howto populate a Multi-line textbox using javascript and vbCrLf

Hi,

I need to poulate a multi-line textbox using document.getElementById("blah").value or document.getElementById("blah").innerHTML

However, my source has <br> tags included in it which also get placed into the textbox.

Can someone provide an example of poupulating the textbox and keeping the carriage returns without displaying <br> tags ?


Thank you,

Nick
0
nickrawlins
Asked:
nickrawlins
1 Solution
 
Tomarse111Commented:
try the below for a simple find and replace function to replace <br> with \n (carriage returns)
<script type="text/javascript">
function populatetext(){
	var text='Hello <br><br>my name is tom';
	var area=document.getElementById('blah');
	
	var re = new RegExp ('<br>', 'gi');
	var text = text.replace(re, '\n');	
	area.value=text;
	
 }
</script>
 
<body onLoad="populatetext()">
<form name="testForm">
<textarea id="blah"></textarea>
</form>
</body>

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now