Calculating A and B vertically from a dropdown combo box has been a challenge. Here is a sample data set:
Data
A B
----------------------------
1 | 1 | 0
2 | 0 | 1
3 | 0 | 1
----------------------------
Result | 1 | 2 (calculation still not functioning as expected)
The goal is to calculate A and B vertically from the dropdown combo box selections and display the results, but unfortunately, the calculation is still not working properly.
Code :
HTML
<select id="k1" class="tes" name="kelayakan1" size="1">
<option value="">-- Choose One --</option>
<option value="1">Eligible</option>
<option value="0">Not Eligible</option>
</select>
<br>
... (more HTML code here)
<br> I want to calculate A and B vertically ..
Javascript
$(document).ready(function() {
//Iterate through each Textbox and add keyup event handler
$(".tes").each(function() {
$(this).change(function() {
//JavaScript code for calculating A vertically goes here
});
});
//Additional JavaScript code for calculating B vertically goes here
//More JavaScript code for handling calculations
jml = total;
$("#hasil1").val(jml);
});
To see this in action, check out the JSFIDDLE example: https://jsfiddle.net/taraym/zo5j7wn9/1/