YegorSSS,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<form action="http://">
<label for="">a = <input type="text"></label>
<label for="">b = <input type="text"></label>
<label for="">c = <input type="text"></label>
<label for="">d = <input type="text"></label>
<p></p>
</form>
<script>
var f = ["a*(b+c*d)", "a+b+c+d", "(a+b)*(c+d)", "a+b", "++a"],
inp = document.querySelectorAll("input"),
p = document.querySelector("p"),
factory = function(a) {
return new Function(a.match(/\w+/g), "return " + a)
},
fn = function(a) {
return a.value = +a.value || 0;
},
res, arr;
document.forms[0].onchange = function() {
arr = Array.prototype.map.call(inp, fn);
res = "";
f.forEach(function(a) {
var b = 0,
c = a.replace(/\w+/g, function() {
return arr[b++]
});
res += a + " => " + c + " => " + factory(a).apply(this, arr) + "<br>"
});
p.innerHTML = res
};
</script>
</body>
</html>