$(document).ready(function() { $('form').change(function() { raknaUtMeritvarde(); }); $('.add_row').live('click', function() { $('div.sample_row > div').clone().appendTo('form.courses'); raknaUtMeritvarde(); }); $('.delete_row').live('click', function() { $(this).parent().slideUp(function() { $(this).remove(); raknaUtMeritvarde(); }); }); }); var courseTitle = false; function raknaUtMeritvarde() { var totalScore = 0; var totalPoints = 0; var subjectScore = 0; var subjectPoints = 0; var meritPoints = 0; $('form.kurser').find('div').each(function() { subjectScore = parseFloat($(this).find("select").val()); subjectPoints = parseFloat($(this).find("input.points").val()); if (isNaN(subjectPoints)) { subjectPoints = 0; } totalPoints = totalPoints + subjectPoints; totalScore = totalScore + (subjectPoints * subjectScore); }); meritPoints = parseFloat($('input.meritpoint').val()); if (isNaN(meritPoints)) { meritPoints = 0; } totalScore = Math.round((meritPoints + (totalScore / totalPoints)) * 100); totalScore = totalScore / 100; if (isNaN(totalScore)) { totalScore = 0; } $('.score_span').html(''); if (totalPoints > 2400) { $('.score_span').append('