<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
</head>
<body>
<script type="text/javascript">
function key(self) {
var doc=document.getElementsByName(self.name);
for(var i in doc) {
if(doc[i]===self) {
alert(i);
}
}
}
</script>
<input type="button" name="butt[]" value="ok0" onclick="key(this)">
<input type="button" name="butt[]" value="ok1" onclick="key(this)">
<input type="button" name="butt[]" value="ok2" onclick="key(this)">
</body>
</html>