Javascript calculation with muliplying

spikiller

New Member
I have 3 text inputs as you can see in this JSFiddleThe thing I need is a JavaScript calculator that will multiply the first input value by 0.04, the second input by 0.04 and the third input by 0.08 and then add all them together and echo it. And it should also echo quantity of three inputs.HTML:\[code\]<form method="post" name="vaartus"> <div>1<input type="checkbox" id="v1" /></div> <div><input type="text" name="v1_v" id="v1_v" disabled="disabled" /></div> <div>2<input type="checkbox" id="v2" /></div> <div><input type="text" name="v2_v" id= "v2_v" disabled="disabled" /></div> <div>3<input type="checkbox" id="v3" /></div> <div><input type="text" name="v3_v" id="v3_v" disabled="disabled" /></div> <div><input type="submit" name="arvuta" value="http://stackoverflow.com/questions/15593321/Arvuta" /></div></form>\[/code\]JavaScript:\[code\]document.getElementById('v1').onchange = function() { document.getElementById('v1_v').disabled = this.unchecked;};document.getElementById('v2').onchange = function() { document.getElementById('v2_v').disabled = this.unchecked;};document.getElementById('v3').onchange = function() { document.getElementById('v3_v').disabled = this.unchecked;};\[/code\]
 
Back
Top