- #1
adjacent
Gold Member
- 1,552
- 63
I am learning Javascript and have made a multiplication table generating program.
But it's about 1000x slower than C#. Is there any problem with this code?
I used the same code as C#, just the syntax is different.
Here is the code:
But it's about 1000x slower than C#. Is there any problem with this code?
I used the same code as C#, just the syntax is different.
Here is the code:
Code:
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Gui</title>
<style>
p{
padding-left:15px;
}
.dc {
height:500px;
overflow:scroll;
border:1px solid black;
}
td >table{border:1px solid #DFE0E4; border-radius:5px;}
</style>
<script>
var mf = function(){
document.getElementById("gui").innerHTML="";
var Of= document.getElementById("of").value;
var From= document.getElementById("from").value;
var To= document.getElementById("to").value;
for(var i=From;i<=To;i++)
{
var ans = Of*i;
document.getElementById("gui").innerHTML += Of +" x "+ i+" = "+ans +"<br>";
}
}
</script>
</head>
<body style="background-color: #E9EAED;">
<table style="width:100%; height:100%;">
<tr>
<td valign="middle">
<table align="center" style="width:100px;padding:5px; background-color: #fff;">
<tr><td>Of:</td><td><input type="number" id="of"></td></tr>
<tr><td>From:</td><td><input type="number" id="from"></td></tr>
<tr><td>To:</td><td><input type="number" id="to"></td></tr>
<tr><td><button type="submit" onclick="mf()">Calculate</button></td></tr>
<tr>
<td colspan="2">
<div class="dc"><p id="gui"></p> </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Last edited: