<input type="text" class="name1" style="width: 500px">
<input type="text" class="name2" style="width: 500px">
<div></div>
<script>
var template = function (name1, name2) {
return "trololololol " + name1 + " dsafdfdsgfds " + name2 + " fdsafdsa";
}
var inputs = document.querySelectorAll("input");
var change = function () {
document.querySelector("div").innerHTML = template(inputs[0].value, inputs[1].value);
}
inputs[0].addEventListener("change", change, true);
inputs[1].addEventListener("change", change, true);
</script>