Javascript replace every line of value -
so have script has find text on first textarea (right away when text pasted), replace 1 , give result textarea.
the problem it's replacing text first line. , want replace on lines.
my code: (doesn't work on jsfiddle, on html)
<script> function go() { var str = document.getelementbyid("a").value; resa=str.replace("http://","www."); resb=resa.replace(".com",""); document.getelementbyid("b").value=resb; } </script> <textarea rows="10" cols="140" onkeyup="go()" id="a"> </textarea> <textarea rows="10" cols="140" onkeyup="go()" onclick="this.focus();this.select();" id="b"> </textarea> so if try enter https://google.com in every line right text on other textarea, in first line.
you need global replace.
var str = document.getelementbyid("a").value; var resa=str.replace(/http\:\/\//g,"www."); var resb=resa.replace(/\.com/g,"");
Comments
Post a Comment