<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>打分拓展</title>
<script type = "text/javascript"></script>
</head>
<body>
<table>
第<span>2</span> 位评委打分:
<input type = "text" value = "" id = "a">
<input type = "button" value = "确定" onClick = "shangchuan()"><br><br><!--添加一个确定按钮,将数据上传-->
<span>最高分:</span>
<input type = "text" value = "" di = "da"><br><br>
<span>最低分:</span>
<input type = "text" value = "" id = "xiao"><br><br>
</table>
</body>
</html>
<script type = "text/javascript">
//点击分数后面的输入框,元数据清除,并且前面加一
//对输入的分数进行比较,显示在最高分和最低分栏里面
window.onload = function(){
}
var arr = [];
n = 0;
function shangchuan(){
//将输入的分数存于数组中
var x = document.getElementById("a");//获取输入的打分
arr[n] = parseInt(x.value);//将打分存入数组
n = n + 1;
x.value = null;//将文本框清空
//取得数组最大值
max();
// var max=getMax();
// document.getElementsByTagName("input")[2].value = max;
// var min=getMin();
// document.getElementsByTagName("input")[3].value = min;
}
/* var show_max = document.getElementsByTagName("input")[2].value;
var show_min = document.getElementsByTagName("input")[3].value;*/
/*for(var a = 0;a < arr.length + 1; a++){
if(max < arr[a]){
max = arr[a];
alert("max");
}
if(min > arr[a]){
min = arr[a];
}*/
function max(){
var max = arr[0];
var min = arr[0];
for(var n in arr){
if(max < arr[n]){
max = arr[n];
alert("max"+max);
}
if(min > arr[n]){
min = arr[n];
alert("min"+min);
}
}
document.getElementsByTagName("input")[2].value = max;
document.getElementsByTagName("input")[3].value = min;
}
/*function getMax(){
var max = arr[0];
for(var n in arr){
if(max < arr[n]){
max = arr[n];
}
}
return max;
}
function getMin(){
var min = arr[0];
for(var n in arr){
if(min > arr[n]){
min = arr[n];
}
}
return min;*/
//}
</script>