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

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:

What is the value of document.colongan.colong?

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]

1 Like

document colongan is textarea for input and output

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.