I'm creating a simple to-do list with checkboxes and progress sliders, and above of all that there is going to be a Total Progress % -bar which takes to count every checked checkbox and the selected value of the sliders.
I have managed to get the checkbox value, which is determined in the HTML as data-value
(I am using pre-defined values in HTML for each step, as the value differs per task) and printed it out successfully, but I do not know how to get the value of the slider
out.
HTML
<tr>
<td valign="top">
<b>Step 1 / layout</b>
</td>
<td valign="top">
<input class="mngr-field" type="checkbox" name="payment_type_mngr_1_01" id="payment_type_mngr_1_01" data-value="10">
<b>Done</b>
</td>
</tr>
<tr>
<td valign="top">
<b>Step 2</b>
</td>
<td valign="top">
<label for="payment_type_mngr_1_02"><input class="mngr-field mngr-slider" type="text" name="payment_type_mngr_1_02" id="payment_type_mngr_1_02" readonly style="border:0; color:#f6931f; font-weight:bold;"> valmis</label>
<div id="slider"></div>
</td>
</tr>
JavaScript
// The Slider
$(function () {
$("#slider").slider({
value: 0,
min: 0,
max: 100,
step: 10,
animate: true,
slide: function (event, ui) {
$(".mngr-slider").val(ui.value + "%");
}
});
sliderval = $(".mngr-slider").val;
$(".mngr-slider").val($("#slider").slider("value") + "%");
});
// Total Progress %
$(".mngr-field").on("change", function () {
var val = this.checked ? $(this).data("value") : '0';
if ($(this).hasClass("mngr-slider")) {
val = sliderval / 10;
}
console.log(val);
});
So basically I am going to get out the slider value and divide it by 10 (as the maximum value of the slider is 100 and so is the maximum value of the Total Progress %.
My purpose is to get the value and sum it all up so there will be one total value rolling out, if you could help me solve this problem and provide at least a tip on how to count it all together, I'll be pleased!