Created
July 30, 2019 15:03
-
-
Save anthony17guty/571c024a58c75678057e75521944d5c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Creacion de jugadores</title> | |
</head> | |
<body> | |
<input type="text" id="jugador" name="jugador"> | |
<br> | |
<input type="text" id="equipo" name="equipo"> | |
<br> | |
<input type="button" id="btnGrabar" value="Grabar"> | |
<br> | |
<input type="button" id="btnMostrar" value="Mostrar"> | |
<br> | |
<table id="tablaJugadores"> | |
<thead> | |
<th>jugador</th> | |
<th>equipo</th> | |
</thead> | |
<tbody id="cuerpoJugadores"> | |
</tbody> | |
</table> | |
</body> | |
<script> | |
// creamos el arrary jugadores onde se va a guardar la informacion | |
var Jugadores=[]; | |
class jugadores{ | |
constructor (nombre,equipo){ | |
this.nombre=nombre; | |
this.equipo=equipo; | |
} | |
} | |
</script> | |
<script> | |
document.getElementById("btnGrabar").addEventListener("click",function(){ | |
var ajugador=document.getElementById("jugador").value; | |
var bjugador=document.getElementById("equipo").value; | |
Jugadores.push(new jugadores(njugador,ejugador)) | |
document.getElementById("jugador").value=""; | |
document.getElementById("equipo").value=""; | |
}) | |
</script> | |
<script> | |
var tablaDeJugadores=document.getElementById("tablaJugadores"); | |
tablaDeJugadores.style.display="none"; | |
document.getElementById("btnMostrar").addEventListener("click",function(){ | |
tablaDeJugadores.style.display="block"; | |
var newTablaJugadores=document.getElementById("cuerpoJugadores"); | |
for(i=0;i<Jugadores.length;i++){ | |
var tr=document.createElement("tr"); | |
var td=document.createElement("td"); | |
var td1=document.createElement("td"); | |
td.appendChild(document.createTextNode(Jugadores[i].nombre)); | |
td1.appendChild(document.createTextNode(Jugadores[i].equipo)); | |
tr.appendChild(td); | |
tr.appendChild(td1); | |
newTablaJugadores.appendChild(tr); | |
} | |
}) | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment