How to eliminate the previous paragraph if the second command is executed?


#1

maybe this is very basic, but without knowledge I find it difficult

 var thisString; function replace() { 
 	thisString = document.colongan.colong.value;  
 	thisString = thisString = thisString.replace(/1/g,"we \n friends");
 document.colongan.colongin.value=thisString ;};

results obtained :
we
friends

if I give a second command like this :

 var thisString; function replace() { 
 	thisString = document.colongan.colong.value;  
 	thisString = thisString = thisString.replace(/1/g,"we \n friends");
 	thisString = thisString = thisString.replace(/2/g," here \n forever");
 document.colongan.colongin.value=thisString ;};

how to get results :
we here
friends forever

maybe the kindheartedly want to explain :blush:


#2

What is the value of document.colongan.colong?


#3

Welcome to the forums @arwahjts

[off-topic]
For future reference, when you post code in the forum, you need to format it. To do so you can either select all the code and click the </> button, or type 3 backticks ``` on a separate line both before and after the code block.

I have done it for you this time.
[/off-topic]


#4

document colongan is textarea for input and output