If you want to replace only the first occurence doing
var newText = a.replace(b, c);
document.getElementById("text3").value = newText;
will do the job.
There is no default method with a string parameter to replace multiple occurences. But the regex version can do this with the global option:
var re = new RegExp("\\b" + b + "\\b", "g");
var newText = a.replace(re, c);
document.getElementById("text3").value = newText;
See also
String.prototype.replace() - JavaScript | MDN[
^] and
Regular Expressions - JavaScript | MDN[
^].