I am writing code for a basic GPA calculator. In principle, this is a table with three columns, two text areas for the name of the course / credit hours and a drop-down list that contains letter ratings (A +, C, B-) and their corresponding point values ββas a parameter value, for example this
<td><select name="letterGrades">
<option value="0.7">A+</option>>
<option value="1.3">A-</option>>
<option value="2.7">C+</option>
</option>
</select>
</td>
I need to iterate through the rows, get the parameter value or "class" for each course.
var table = document.getElementById(tableID);
for(var i=0; i<rowCount; i++) {
grade = table.rows[i].cells[2].options[letterGrades.selectedIndex].id;
credits = parseFloat(table.rows[i].cells[1].value);
totalHours += parseFloat(table.rows[i].cells[1].value);
perCourse += grade*credits
}
totalGPA = perCourse/totalHours;
I understand that there are other ways to assign letters to their point values ββ(arrays?), But I still don't know how to iterate through the drop-down lists and get their parameter values.