0

hi i need to add button thath allow to print out list my script display on the screen, i try few thing but button always dissapear after i display list.
can someone help me?
this is my script code:

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <script>

    var teams = Array(), index = 0;

    function registerTeam()
    {
       //we check if we have 10 elements in array, if so we go to displayTeams function
       if(index == 9){
          teams[index] = document.getElementById('name').value;
          displayTeams();
       //if not, we put data to array
       }
    else{
       teams[index] = document.getElementById('name').value;
       document.getElementById('name').value = '';
       }
       index++;

    }

    function displayTeams()
    {
       for(var i = 0; i < 10; i++)
       {
          document.write(i+". "+teams[i]+"<br>");
       }
    }
    //printout data from array in order list ;)

    </script>
    </head>
    <body>

    <div id="registration">
       <label>Enter name of team: </label><input id="name" type="text"><button onClick="registerTeam()">Register</button>
    </div>
    <div id="list"></div>


    </body>
    </html>
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by mbarandao
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.