Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a simple JavaScript program in HTML file to show the table of any entered

ID: 3611762 • Letter: W

Question

Write a simple JavaScript program in HTML file to show the table of any entered number. Follow these directions for it: Use HTML form, with one text box and a button as shown below: Enter a number: Text box is to enter the number and when you press the "Have a Table" button a table of entered number should be shown. Use loop to print the table Output should be as shown below (if 5 is entered): 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 1 0 = 50

Explanation / Answer

<html>
<head>
<script language ="javascript">
function table()
{
var n=document.f1.num.value
var outp=""
for(i=1;i<=12;i++)
{
mul=n*i;
outp = outp+n +" x "+i+"="+mul+"<BR>"

}
document.getElementById('outtab').innerHTML = outp
}
</script>
</head>
<body>
<form name="f1" >
Enter a number: <input type="text" name="num"/><br>
<input type="button" value="Have a table"/>
</form>
<BR><SPAN ID="outtab"></SPAN>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote