Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting line breaks in a textarea 1

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
How does one write a new line to the inner HTML of a textarea using js? \n is added to the string, but it displays in the textarea without breaking.

Code:
function addPO() {
	
	var contact_pos = document.getElementById('contact_pos').innerHTML;
	var po = document.getElementById('po').value;
	
	alert(po);
	
	if ( contact_pos.length != 0 ) {
	document.getElementById('contact_pos').innerHTML = contact_pos + '\n' + po;
	}
	else
	{
	document.getElementById('contact_pos').innerHTML = po;
	}
	
}
 
Oh, I didn't even know you could use .value with a textarea. I thought one had to use innerHTML.

Thanks Dan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top