Share on Google+Share on Google+

Ravi Kumar
html
2 Answer(s)      6 years and 4 months ago
Posted in : HTML

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

Ads

View Answers

December 14, 2010 at 11:34 AM


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>


December 14, 2010 at 12:15 PM


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:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<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










Related Tutorials/Questions & Answers:
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
Advertisements
HTML
HTML  What is SPAN in HTML
html
html  How to add the calendar in html code
HTML
HTML  What is BODY in HTML document
HTML
HTML  What is HTML? What is a Hypertext link
HTML
HTML  What is HTML? What is a Hypertext link
html
html  diffrence between html and xml
Html
Html  What is HTML? What is a Hypertext link
html
add a header in the html page  what we can do to add a header in the html page
HTML
HTML  how can we give the unlimited size in the html
html
html  what we can do to add a header in the html page
html
html  what we can do to add a header in the html page
html
html  i want a registration page in html with good background
html
html  how to convert html page into jsp page
HTML
HTML  What is a tag? How can we use MARQUEE in HTML
HTML
HTML  How do we specify page breaks in HTML
HTML
HTML  Hi, What is the full form of HTML? Thanks   Hi, The HTML stands for HyperText Markup Language. HTML is used to create webpage for world wide web. Web pages are accessed by web browsers and then shown
html
html  sir i am new to eclipse and i am created a html program and also tomcat is running successfully in side the eclipse.but now how i deploy that html program in the eclipse
HTML
HTML  How do we create a link? What are the three types of form tags in HTML
html
Adding Header in HTML  what we can do to add a header in the html page
html
html  how we can give the form actions in html after register button in the login page
html
html  Can we Access database through html page and how,if not then why
html
html  For what is used HTML?   Using HTML we can create a Web Page which can be viewed through a Web Browser over Internet. HTML describes... or the End Tag is defined as </> . The whole HTML document is enclosed
Html
Html  in the web page if judge select the age and category then automatically under that conditions the details will be display in the form of grid give me that code in html and java
html
html   write a html program to print "HELLO WORD"in red coaler font size 12 and italic stile   Here is a html code that display the message "Hello World" in red font with size 12 and in italics. <html> <
Html
Html  i am select the dateofbirth through the html browser.but it can not save into the sql server 2008 database.any special code required to store the date in database by using java servlets
HTML
HTML  how can we design the gird form view in html i want the following fields in the grid form The fields are Name of the candidate,Title... me the coding for this in html
HTML
HTML  in html how can we can upload the file <tr> <td><strong>Video of the work:</strong> <td><b>... the file give me the code for this in html and java
HTML
HTML  I have created an info.html file for the applet.The class file is located in a directory different from the HTML file.The info.html file I have created is below. <HTML> <HEAD> <BODY> <APPLET Code
Html
:48:44 PM Author : SAMSUNG --%> <[email protected] contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...; <head> <meta http-equiv="Content-Type" content="text/html
Tutorials   
Java Spring Hibernate Struts Training How to display button as a link in vaadin? hi change navbar dropdown color in bootstrap How to remove the background color of bootstrap menu bar? How to change color of opened Bootstrap drop down toggle? Setting bootstrap container background color Help school all activities and admision process.. add one row after another date make a webpage HTMl HTMl Source code how to apply globalisation to a world wide asp.net application how to print HTML using javascript or Jquery How to recover from google panda update? How to survive google panda 4.0 update How to find if you have been hit by Panda 4.0 Design a web page using XHTML and JavaScript that does the followings: ffmpeg converting file mp4 to mov JavaScript How to Disable Catch-all Emails on CPanel z-index always on top What is Web hosting Database and HTML web development trainee Uploading files Image Gallery Image Gallery dropdown How to redirect from a HTML page? Easiest method for expiring the css and js headers HTML WITH AJAX VB 6 Read Web Page Header string palindrom using vbscript? html button How to add mod_deflate to apache without recompiling How to use place hoder in IE(version : 8) Html Software Question div align left css Fetching data from excel file on other website and display in interactive graph form where do I find the fix for tree view catalog not expanding and collapsing correctly for roseindia shopping cart 1.1 pass to next page to enter into a particular page only if the username,password and listbox value mtches hi Cricket stadium ticket booking design Need some help creating an order form. HTML div tag HTML div tag

Ads

 
Advertisement null

Ads