<html>
<body>
<p id="myP">How many characters in this sample text?</p>
<button onclick="function1();">Click me to find out</button>
<script language="JavaScript"> function function1() {
var m = "How many characters in this sample text?".length;
alert(m);
}
</script>
</body>
</html>