- ARCHIVE / Javascript
- Javascript-Session 2-Multiplication Table 3
A multiplication table where the number of rows are randomly generated from a number between 10 and 20 by passing on the variable RandomNumRow; and columns from 1 to 5 by passing on the variable RandomNumCol. Here is the link, refresh to generate new numbers.
<html>
<body>
<script language=”JavaScript”>
document.write(’<table border=0>’);
//—creates random number for rows—
minimum = 10;
max = [...] - Javascript-Session 2-Multiplication Table 2
A multiplication table where the number of rows and columns are randomly generated from a number between 1 and 10 by passing on the variable RandomNum. Here is the link, refresh to generate a new number.
<html>
<body>
<script language=”JavaScript”>
document.write(’<table border=0>’);
minimum = 1;
max = 10;
numb = genRand(minimum, max); //call function, pass and receive data
function [...] - Javascript-Session 2-Multiplication Table 1
A multiplication table where the number of rows and columns are set by the variables: rowNum and colNum. A link to the table is here.
<html>
<body>
<script language=”JavaScript”>
document.write(’<table border=0>’);
var rowNum = 20
var colNum = 10
//—creates index(red) row ‘X’ through number set in “var colNum”—
document.write(’<tr style=color:red>’);
document.write(’<td>’+’X’+’</td>’);
for (row1=1; row1<=colNum; row1++)
{
document.write(’<td>’+row1+’</td>’);
}
document.write(’</tr>’);
//—
var col1=1
for (row=1; row<=rowNum; row++)
{
document.write(’<tr>’);
//—creates index(red) column, number of rows [...] - Javascript-Session 1-Objects
Retrieving a property from an object. Below the name and address properties are pulled from the designOffice object. First using a variable then using the objects path. Online link here.
<html>
<head>
<title>Objects</title>
</head>
<body>
<h1>Objects</h1>
<script language=”JavaScript”>
document.write(”<h2>Retrieving a property of an object</h2>”);
var designOffice = {name : “Pentagram”,
address : “204 Fifth Avenue”,
city : “New York”,
state : “NY”,
zip : 10010
};
var list = designOffice.name;
document.write(’The [...] - Javascript-Session 1-Arrays
Creating an array and writing the third element in the array. Online here.
<html>
<head>
<title>Array</title>
</head>
<body>
<h1>Array</h1>
<script language=”JavaScript”>
document.write(”<h2>Output third element</h2>”);
var graphicDesigners=new Array(3);
graphicDesigners[0]=”Woody Pirtle”;
graphicDesigners[1]=”Michael Bierut”;
graphicDesigners[2]=”Paula Scher”;
graphicDesigners[3]=”Michael Gericke”;
graphicDesigners[4]=”Abbott Miller”;
document.write(”1. ” + graphicDesigners[0] + “<br />”);
document.write(”2. ” + graphicDesigners[1] + “<br />”);
document.write(”3. ” + graphicDesigners[2] + “<br />”);
document.write(”4. ” + graphicDesigners[3] + “<br />”);
document.write(”5. ” + graphicDesigners[4] + “<br />”);
document.write(”<br />”);
document.write(”The third [...] - Javascript-Session 1-Variables
Multiplication where numbers to be multiplied, the result and output are determined by variables. Online here.
<html>
<head>
<title>Variable</title>
</head>
<body>
<h1>Multiply</h1>
<script language=”JavaScript”>
document.write(”<h2>var num and num2</h2>”);
var num = 4;
var num2 = 6;
var num3 = num * num2;
document.write(num + ” x “+ num2 + ” = ” + num3);
</script>
</body> - Javascript-Session 1-Table Using document.write
A table only using document.write. Online here.
<html>
<head>
<title>document.write Table</title>
<style type=”text/css”>
<!–
table {border:0; width:400px;}
.color {color:red}
–>
</style>
</head>
<body>
<h1>Table</h1>
<script language=”JavaScript”>
document.write(”<h2>Multiplication Table</h2>”);
document.write(”<table>”);
document.write(”<tr class=color><td>X<td>1<td>2<td>3<td>4<td>5<td>6<td>7<td>8<td>9<td>10″);
document.write(”<tr><td class=color>1<td>1<td>2<td>3<td>4<td>5<td>6<td>7<td>8<td>9<td>10″);
document.write(”<tr><td class=color>2<td>2<td>4<td>6<td>8<td>10<td>12<td>14<td>16<td>18<td>20″);
document.write(”<tr><td class=color>3<td>3<td>6<td>9<td>12<td>15<td>18<td>21<td>24<td>27<td>30″);
document.write(”<tr><td class=color>4<td>4<td>8<td>12<td>16<td>20<td>24<td>28<td>32<td>36<td>40″);
document.write(”<tr><td class=color>5<td>5<td>10<td>15<td>20<td>25<td>30<td>35<td>40<td>45<td>50″);
document.write(”<tr><td class=color>6<td>6<td>12<td>18<td>24<td>30<td>36<td>42<td>48<td>54<td>60″);
document.write(”<tr><td class=color>7<td>7<td>14<td>21<td>28<td>35<td>42<td>49<td>56<td>63<td>70″);
document.write(”<tr><td class=color>8<td>8<td>16<td>24<td>32<td>40<td>48<td>56<td>64<td>72<td>80″);
document.write(”<tr><td class=color>9<td>9<td>18<td>27<td>36<td>45<td>54<td>63<td>72<td>81<td>90″);
document.write(”<tr><td class=color>10<td>10<td>20<td>30<td>40<td>50<td>60<td>70<td>80<td>90<td>100″);
document.write(”</table>”);
</script>
</body>