If User inputs 2 then output will be:-
2x1
|
=
|
2
|
2x2
|
=
|
4
|
2x3
|
=
|
6
|
2x4
|
=
|
8
|
2x5
|
=
|
10
|
2x6
|
=
|
12
|
2x7
|
=
|
14
|
2x8
|
=
|
16
|
=
|
18
|
|
2x10
|
=
|
20
|
Ans:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script>
function sai() {
var no = document.getElementById("txtno").value;
for (var i = 1; i < 11; i++) {
var res = no * i;
document.write("<table border=1><tr><td>"+no+"</td><td>"+"*"+"</td><td>"+i+"</td><td>" + "=" + "</td><td>"+res+"</td></tr></table>");
}
alert(no)
}
</script>
</head>
<body>
<table>
<tr>
<td>
<input id="txtno" type="text" />
</td>
<td>
<input id="Submit1" type="submit" onclick="sai()" value="submit" />
</td>
</tr>
</table>
</body>
</html>
No comments:
Post a Comment