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