<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("button1").name;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="button" onclick="displayResult()" id="button1" name="button1" value="Display name">
</form>
</body>
</html>