Write an HTML file with one button. The value of the button should be your name.
ID: 3577009 • Letter: W
Question
Write an HTML file with one button. The value of the button should be your name. Name the file YourFirstNameYourLastName.html Write a separate JavaScript file called YourFirstNameYourLastname.js in the same folder. When the button is clicked, the program should prompt the user for a string, or *** to quit. It should read the string into a variable. Assume the user enters a lowercase only string. After the user has entered a non-*** string, the program should print the number of spaces in the string, and the number of vowels.Explanation / Answer
1) RajeshBabu.html
<html>
<head>
<title>progrm1</title>
</head>
<body>
<button type="button">RajeshBabu</button>
</body>
</html>
2).RajeshBabu.js
3.)
<html>
<head>
<title>finding the vowels count</title>
<script type="text/javascript">
function GetVowels()
{
var str = document.getElementById('txtname').value;
var count = 0, total_vowels="",total_spaces=0;
for (var i = 0; i < str.length; i++)
{
if (str.charAt(i).match(/[a-zA-Z]/) != null)
{
// finding the Vowels
if (str.charAt(i).match(/[aeiouAEIOU]/))
{
total_vowels = total_vowels + str.charAt(i);
count++;
}
}
if(str.charAt(i) === " ")
{
total_spaces++;
}
}
document.getElementById('vowels').value = total_vowels;
document.getElementById('vcount').value = count;
document.getElementById('spaces').value = total_spaces;
}
</script>
</head>
<body>
<div >
<table border="1px" cellspacing="0" width="30%">
<tr><td colspan="2" align="center"><b>finding vowels from the string</b></td></tr>
<tr>
<td>Enter Text :</td>
<td><input type='text' id='txtname' /></td>
</tr>
<tr>
<td>total no.of Vowels:</td>
<td><input type='text' readonly="readonly" id='vcount'/></td>
</tr>
<tr>
<td>Total Vowels present in the string :</td>
<td><input type='text' readonly="readonly" id='vowels' /></td>
</tr>
<tr>
<tr>
<td>Total spaces present in the string :</td>
<td><input type='text' readonly="readonly" id='spaces' /></td>
</tr>
<tr>
<td>
</td>
<td><input type='button' value='Get Vowels Count' /></td>
</tr>
</table>
</div>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.