Is there a way for this? What I want to happen is the hyperlinks from the left side will have sum totals, and so on and on the final page/tab, the summation of all the hyperlinks will be shown there. Here's a jsFiddle to better understand my point https://jsfiddle.net/nerdfighter/121myofn/1/
Here's the initial JavaScript code I wrote in adding the checked chekcboxes
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
window.onload = function() {
var inputs = document.getElementsByClassName('sum'),
total = document.getElementById('payment-total');
for (var i = 0; i < inputs.length; i++) {
inputs[i].onchange = function() {
var add = this.value * (this.checked ? 1 : -1);
total.innerHTML = parseFloat(total.innerHTML) + add
var new_total = parseFloat(document.getElementById('input').value);
console.log(new_total);
document.getElementById('input').value = new_total + add
}
}
}
</script>
This is just a small project and I don't I won't be using server-side.
Aucun commentaire:
Enregistrer un commentaire