Pregunta

I want to insert two texts into one text area using javascript.

I am getting plain text from Wikipedia but I can't seem to two or more article sections into the text area.

I use the code bellow for inserting the text for both sections into the text area.

pText = pText.substring(0, pText.length - 2); //Remove extra newline
pText = pText.replace(/\[\d+\]/g, ""); //Remove reference tags (e.x. [1], [4], etc)
document.getElementById('textarea').value = pText

http://jsfiddle.net/LUTW4/

¿Fue útil?

Solución

document.getElementById('textarea').value += pText;

To add old text of the text area and new text , just concate it using +

This is nothing but ,

document.getElementById('textarea').value = document.getElementById('textarea').value + pText;

Fiddle:http://jsfiddle.net/LUTW4/2/

Otros consejos

You can append more texts by

 document.getElementById('textarea').value = pText
 document.getElementById('textarea').value += newText

or even join both by

pText = pText+newText;
document.getElementById('textarea').value = pText 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top