I have a simple form in javascript. I'm going to calculate a formula.
I want to select elements by id and then detects operators and finally calculate final result.
<p>
V1: <input id="v1" />
</p>
<p>
V2: <input id="v2" />
</p>
<p>
V3: <input id="v3" />
</p>
<p>
V4: <input id="v4" />
</p>
<p>
Fromula: <input id="f1" />
</p>
<p>
<button id="doAction">
Calculate
</button>
</p>
Example expression is: (v1+v2)*v3-(v4-v1)/v2
document.getElementById()and experiment with it. Also make sure to convert the.valuesof the input fields into numeric values before adding them to other values using the+operator.^is in your context?