Slip 22 - A) Write a java script code to accept a string and write a function to calculate length of string

Solution:


<HTML>
<script>
function find()
{
var str=frm.txt1.value;
37
var n = str.length;
alert("length of string is: "+n);
}
</script>
<form name="frm">
Enter a String:<input name="txt1" type="text" />
<input name="b1" onclick="find();" type="button" value="display" /></form>
</BODY>
</HTML>

Post a Comment

0 Comments