Web 8,9,10
Web 8,9,10
Web 8,9,10
<html>
<body>
<script>
function myFunction() {
let text;
} else {
</script>
</body>
</html>
b.
<html>
<body>
<script>
let x = 125;
document.getElementById("demo").innerHTML =
x.toString() + "<br>" +
(125).toString() + "<br>" +
(100 + 25).toString();
</script>
</body>
</html>
9.a. Write a JavaScript that calculates the squares and cubes of the numbers
from 0 to 10
and outputs HTML text that displays the resulting values in an HTML table
format.
<html>
<head>
<script>
document.write('<h1 align="right">Squares and Cubes of the numbers from 0 to 10</h1>');
document.write('<center><table width="30%" border="1" bgcolor="white">');
document.write( "<tr> <th>Number</th> <th>Square</th> <th>Cube</th> </tr>" ) ;
for(var n=0; n<=10; n++)
{
document.write( "<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n + "</td></tr>" )
;
}
document.write( "</table>" ) ;
</script>
</head>
</html>
9.b. Write a JavaScript code that displays text “TEXT-GROWING” with increasing font
size in the interval of 100ms in RED COLOR, when the font size reaches 50pt it
displays “TEXT-SHRINKING” in BLUE color. Then the font size decreases to 5pt.
<html>
<body>
<p id="myP1">TEXT-GROWING.</p>
<p id="myP2">TEXT-SHRININKING</p>
</body>
<script>
//Global declerations
var size = 10;
vari =0;
var myWait1 = setInterval(GrowText1, 100);
function GrowText1()
{
if(size<51)
{
size = size + 1;
document.getElementById("myP1").style.fontSize = (size+'pt');
document.getElementById("myP1").style.color = "red";
//Hide the paragraph "text-shriniking"
document.getElementById("myP2").style.visibility = "hidden";
}
else
{
clearInterval(myWait1);
myWait1 = setInterval(ShrinkText1, 100);
//Now hide the 1st paragraph and display the second paragraph
document.getElementById("myP1").style.visibility = "hidden";
document.getElementById("myP1").style.fontSize = '1pt';
document.getElementById("myP2").style.visibility = "visible";
}
}
function ShrinkText1()
{
if(size>5)
{
size = size - 1;
document.getElementById("myP2").style.fontSize = (size+'pt');
document.getElementById("myP2").style.color = "blue";
}
else
{
clearInterval(myWait1);
}
}
</script>
</html>
10. Develop and demonstrate a HTML5 file that includes JavaScript script that uses
functions for the following problems:
a. Parameter: A string
b. Output: The position in the string of the left-most vowel
c. Parameter: A number
d. Output: The number with its digits in the reverse order.
<html>
<head><title>3A PROGRAM</title>
<SCRIPT>
function vow(st)
{
var pos;
pos=st.search(/[aeiouAEIOU]/);
if(pos<0)
alert("pattern not found\n");
else
alert("Position of the left most vowel is "+(pos+1));
}
</SCRIPT>
</head>
<body>
<FORM><p>Enter the text</p>
<input type="text" id="voweltext"/>
<input type="button" value="Click here" onclick="vow(voweltext.value);"/>
</FORM></body>
</html>
c. Parameter: A number
d. Output: The number with its digits in the reverse order
<html>
<title>Reverse Number</title>
<script>
function rev()
n=parseInt(n);
var temp=0,rev=0;
while(n>0)
temp=n%10;
rev=rev*10+temp;
n=n/10;
n=parseInt(n);
</script>
<body>
<form>
</form>
</body>
</html>