I am looking for correct code so function named "finder()" can execute and find the highest value in Array named "sum" . When press "Find max" button result is :"[object HTMLInputElement] " Thank you for any help! Here is code:
<html>
<head>
<title>Max</title>
<meta charset="utf-8">
<script type="text/javascript">
var sum = document.getElementsByName('addends');
function add() {
var x = document.getElementById('apendiks');
x.innerHTML+="<br/><input type='text' name='addends' size='7'>";
}
function finder() {
var max = sum[0];
for(i=0; i<sum.length;i++){
if(sum[i] > max){
max = sum[i];
}
}
document.getElementById('showMaxValue').innerHTML = max;
}
function gather() {
var total=0;
for(i=0; i < sum.length; i++){
total+=parseFloat(sum[i].value);
}
document.getElementById('score').innerHTML = total;
}
</script>
</head>
<body>
<p><input type="button" onclick="add()" value="Add a new box"> </p>
<p><input type="button" onclick="" value="-"> </p>
<div id="apendiks"></div>
<p><input type="button" onclick="gather()" value="Total sum"> </p>
<p>Score: <b id="score"></b></p>
<p><input type="button" onclick="finder()" value="Find max"> </p>
<p id="showMaxValue"></p>
</body>
</html>