I'm hoping someone can help, I'm new to Javascript but not HTML/CSS. I'm having a small issue trying to display some Javascript values onto my HTML page. So in a nutshell:
I have two form range sliders the values from these inputs then use JavaScript to work out the total including interest (it's a loan calculator). However what I need is to display the sum at the bottom of the form so:
Amount Borrowed [value] + Interest [value] = Total repay [value]
I need this to update the values as they are sliding the input range, I can't have the user needing to click a button.
Here is my JS:
<script type="text/javascript"><!--
function updatesum() {
document.form.sum.value = (document.form.borrow.value -0 + 5.5) / 100 *
(document.form.duration.value -0) + (document.form.borrow.value -0 + 5.5);
}
//--></script>
My HTML:
<form name="form" class="form">
<label for="borrow">How much would you like to <span>borrow</span>?</label>
<input type="range" name="borrow" id="borrow" value="150" min="1" max="400" onChange="updatesum()" style="color: #1271a9;">
<label for="duration">How <span>long</span> for?</label>
<input type="range" name="duration" id="duration" value="18" min="1" max="38" onChange="updatesum()" style="color: #1271a9;">
<label>Total Repayable:</label>
<input name="sum" readonly style="color: #1271a9; font-weight: bold;">
<p class="sum">Borrowing <div id="sumBorrow"><span>[sum]</span></div> + Interest & fees <span name="duration">[sum]</span> = Total to repay <span name="sum">[sum]</span></p>
</form>