Logo 
Search:

Javascript Forum

Ask Question   UnAnswered
Home » Forum » Javascript       RSS Feeds

Taking input from user and printing stars

  Asked By: Nauman    Date: Apr 28    Category: Javascript    Views: 3319
  

Hi,


I am trying to create a program in HTML using JavaScript. In which i want to take input from user in number and want to print the stars "*" of that number.

Kindly help and reply me with the accurate code.

Thanks


My Code is:


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<script>
function PrintStars() {

var x = 0;
var y = 10;

for(x=0;x<10;x++)
{
for(y=0;y<=x;y=y+1)
{
document.getElementById("TableArea").innerHTML="<br>" + document.getElementById("etext").value;
document.write = "*";
}
}
}
</script>

<body>
Enter a Number: <input id="etext" type="text" placeholder="Enter a number here"/>
<p id="TableArea"></p>
<input type="button" Value="Print" onclick="PrintStars();"/>
</body>
</html>

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Taking input from user and printing stars Or get search suggestion and latest updates.




Tagged: