
HTML document with Javascript to count the number of vowels in a text typed in text area. please send the code.

Hi Ravi
Here is the code ..I hope this will solve your problems :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Vowel Count </TITLE>
<SCRIPT LANGUAGE="JavaScript">
function MsgBox (str) {
var chr = ""
var nVowels = 0
//Counting all the vowels.
for (pos = 0; pos < str.length; pos++){
chr = str.charAt(pos)
if (chr == "a" || chr == "e" || chr == "i" || chr == "o" || chr == "u" ||
chr == "A" || chr == "E" || chr == "I" || chr == "O" || chr == "U") nVowels++
}
alert ("There were " + nVowels + " vowels")
document.write("<P>There were " + nVowels + " vowels.</P>")
}
</SCRIPT>
</HEAD>
<BODY>
<FORM>
<h2><font color=red>Type any thing to count number of vowels</font></h2>
<INPUT NAME="text1" TYPE=Text>
<INPUT NAME="submit" TYPE=Button VALUE="Show Me" onClick="MsgBox(form.text1.value)">
</FORM>
</BODY>
</HTML>

Hi Friend,
Try the following code:
<html>
<script>
function countVowels(){
var str=document.form.data.value;
var vowels = "aeiouAEIOU"
var ch = ""
var count = 0
for(pos = 0; pos < str.length; pos++){
ch = str.charAt(pos)
if (vowels.indexOf(ch) != -1) count++
}
document.form.no.value=count;
}
</script>
<form name="form" method="post">
Enter Text:             <textarea name="data" rows="5" cols="20"></textarea><br>
Number of Vowels:<input type="text" name="no"><br>
<input type="button" value="Count" onclick="countVowels();">
</form>
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.