0% found this document useful (0 votes)
33 views

HTML

The document contains 5 code snippets. The first snippet defines a multiplication table function that generates a multiplication table as an HTML table and displays it. The second snippet defines a compute function that calculates the sum of all multiples of 3 and 5 up to a given number. The third snippet defines a printnumber function that displays consecutive numbers separated by spaces. The fourth snippet contains sample HTML and JavaScript code. The fifth snippet defines a combine function that concatenates corresponding elements from letter and number arrays, separated by commas.

Uploaded by

Mynheil Arellano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

HTML

The document contains 5 code snippets. The first snippet defines a multiplication table function that generates a multiplication table as an HTML table and displays it. The second snippet defines a compute function that calculates the sum of all multiples of 3 and 5 up to a given number. The third snippet defines a printnumber function that displays consecutive numbers separated by spaces. The fourth snippet contains sample HTML and JavaScript code. The fifth snippet defines a combine function that concatenates corresponding elements from letter and number arrays, separated by commas.

Uploaded by

Mynheil Arellano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

NUMBER1

<html>
<head>
<title>Multiplication table</title>
</head>
<body>
<div id="Multiplication Tables";></div>
<button name="PMT" onclick="printMT();">Multiplication Table</button>
</body>
</html>

<script>
function printMT(){
var i, j, k;
var str;
var num = 15;
str = "<table border = '2px'>";
//alert(str);
for(i = 1; i <= num; i++){
str +="<tr>";
for(j = 1; j <= num; j++){
str +="<td style='width:35px'>";
k = i*j;
str += k.toString();
str +="</td>";
}
str +="</tr>";
}
str += "</table border>";
//alert(str);
document.getElementById("Multiplication Tables").innerHTML = str;
}
</script>
NUMBER2
<html>
<head> Multiple of Three and Five </head>
Value of N: <input id="value" type="text">
<input type="button" value="Compute" onclick="compute()">
<script>
function compute()
{
var n=document.getElementById("value").value;
var fiveN=parseInt(n/5);
var threeN=parseInt(n/3);
var result=[];
for(var c=1;c<=threeN;c++)
result.push(3*c);
for(var c=1;c<=fiveN;c++)
result.push(5*c);

for(var r=0;r<result.length;r++)
{
for(var c=r+1;c<result.length;c++)
{
if(result[r]>result[c])
{
var temp=result[r];
result[r]=result[c];
result[c]=temp;
}
}
}
var temp="";
var sum=0;
for(var c=0;c<result.length;c++)
{
temp+=" "+result[c];
sum+=result[c];
if(result[c]==result[c+1])
c++;
}
alert(temp+" "+" The sum of the numbers is = "+sum);
}
</script>
</html>
NUMBER3

<script>
function printnumber(){
var num = document.getElementById("num");
var i;
var str = "";
var n = parseInt(num.value);
for(i = 1; i <= n; i++){
str += i + "&nbsp;";
}
document.getElementById("numbers").innerHTML = str;
}
</script>

NUMBER5
<html>
<head></head>
<input onclick="combine()" type="button" value="Combine Letters and Number">

<script>
function combine()
{
var result="";
var number=[1,2,3];
var letter=['a','b','c'];
for(var c=0;c<letter.length;c++)
{
result+=letter[c]+","+number[c];
if(c<letter.length-1)result+=",";
}
document.write(result);
}
</script>
</html>

You might also like