display the inserted value in java

Array Program
<html>
<head>
<title> java tutorial...</title>
<style type="text/css">
#d1{
background-color: cyan;
color:black;
height:40%;
width:60%;
}
</style>
<script type="text/javascript">
var x=[];
function insert()
{

for(var i=0;i<3;i++)
{
      var y=[];
     for(var j=0;j<3;j++)
  {
  y.push(j);
  }
x.push(y);
}
}
function display(){
for(var i=0;i<3;i++)
{
   for(var j=0;j<3;j++){
document.getElementById("d1").innerHTML+= x[i][j]+" ";
}
document.getElementById("d1").innerHTML+="<br>";
              }
  
     
}
</script>
</head>
<body>
<input type="button" value="add element" onclick="insert()"/>
<input type="button" value="display" onclick="display()"/>
<div id="d1">

</div>
</body>
</html>



Output:











Post a Comment

0 Comments