I somehow done what I wanted but at the moment the calculation happens on change of dropdown option selection (I have added onchange="calculate(this)" event to the dropdown list in HTML). But I want to do calculation only when I press "Coolculate" button which has an ID "coolculate".
Here is the GIF of how it works at the moment: https://viki.b-cdn.net/gif_xnVXGSpD.gif
At the moment my code is looking like this:
<script>
var input1 = document.getElementById("inp1");
var input2 = document.getElementById("inp2");
var e = document.getElementById("m_or_f");
var value = e.value;
var result = document.getElementById("coolculate");
function calculate(answer) {
if(answer.value == 1) {
var theProduct = parseInt(input1.value) * parseInt(input2.value) * (0.15);
document.getElementById('invest_output_result').innerHTML = theProduct.toFixed(1);
} else if (answer.value == 2) {
var theProduct = parseInt(input1.value) * parseInt(input2.value) * (0.014);
document.getElementById('invest_output_result').innerHTML = theProduct.toFixed(1);
} else {
var theProduct = 0;
}
};
result.onclick = calculate;
</script>