I need to create a mini calculator which involves changing input values, doing a little bit of addition etc then updating div's with the value of the inputs.
$('.skillcount').change(function() {
var value = parseFloat($(this).val()) / 2;
alert(value);
$(".missed").append('value');
});
Fiddle: http://jsfiddle.net/5De46/65/
$('.skillcount').change(function() {
var value = parseFloat($(this).val()) / 2;
alert(value);
$(".missed").append('value');
});
// value from span .missed + 1498
$('.missed').change(function() {
var value = parseFloat($(this).val()) + 1498;
alert(value);
$(".cost").append('value');
});
// value from skillcount - value from '.cost'
$('.skillcount').change(function() {
var value = parseFloat($(this).val()) - $('.cost');
alert(value);
$(".remaining").append('value');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- enter an amount - default 1000 -->
<input type="text" class="skillcount" name="skillcount" value="1000" />
<p>
<!-- that ammount from skillcount divided by 2 and added into '.missed' -->
Missed: £
<span class="missed"></span>
</p>
<p>
<!-- Take output value of the paragraph '.missed' and + 1498 to it -->
True Cost: £
<span class="cost"></span>
</p>
<p>
<!-- Value of skillcount 'minus' value of the paragraph '.cost' -->
Remaining: £
<span class="remaining"></span>
</p>
I have put all comments and explanations in the fiddle in more detail. I just don't know how to take the values from the output and place them into the paragraph then use the values to do more basic calculations.