$("#calculate").click(function(){ var lowerLimits = $('#lowerlimits').val().split(", "); var upperLimits = $('#upperlimits').val().split(", "); var frequencies = $('#frequencies').val().split(", "); var computation = 0; if(lowerLimits && lowerLimits.length > 0 && lowerLimits[0] !== ""){ var maxFrequency = 0; var maxFrequencyIndex = 0; for(var i = 0; i< frequencies.length ; i++){ if(parseFloat(frequencies[i]) > maxFrequency){ maxFrequency = parseFloat(frequencies[i]); maxFrequencyIndex = i; } } var L = lowerLimits[maxFrequencyIndex]; var f_0 = frequencies[maxFrequencyIndex-1]; var f_2 = frequencies[maxFrequencyIndex+1]; var interval = parseFloat(upperLimits[0]) - parseFloat(lowerLimits[0]); computation = parseFloat(L) + ((maxFrequency - f_0)/(2* maxFrequency - f_0 - f_2))*interval; } $('#result').text(parseFloat(computation).toFixed(2)); }); $("input").change(function(){ var isInvalid = $('#itemDiv').hasClass('is-invalid') || $('#frequencyDiv').hasClass('is-invalid'); if(isInvalid){ $("#add").prop("disabled", true); }else{ $("#add").removeAttr('disabled'); } }); $("#add").click(function(){ var lowerlimits = $('#lowerlimits'); var upperlimits = $('#upperlimits'); var lowerLimit = $('#lowerlimit').val(); var upperLimit = $('#upperlimit').val(); var listOfLowerLimits = lowerlimits.val(); var listOfUpperLimits = upperlimits.val(); var frequencies = $('#frequencies'); var frequency = $('#frequency').val(); var listOfFrequencies = frequencies.val(); if(lowerLimit && lowerLimit.length > 0 && upperLimit && upperLimit.length > 0 && frequency && frequency.length > 0){ if(listOfLowerLimits && listOfLowerLimits.length > 0){ listOfLowerLimits += ', ' + lowerLimit; listOfUpperLimits += ', ' + upperLimit; listOfFrequencies += ', ' + frequency; }else{ listOfLowerLimits = lowerLimit; listOfUpperLimits = upperLimit; listOfFrequencies = frequency; } $('#itemList').append("" + lowerLimit + '-' + upperLimit + ""); $('#frequencyList').append("" + frequency + ""); } lowerlimits.val(listOfLowerLimits); upperlimits.val(listOfUpperLimits); frequencies.val(listOfFrequencies); });

Enter Item's Range & Frequency (Ascending Order) and Press Add Button.

Number required!
Number required!
Number required!
Items
Frequency