diff --git a/damas.html b/damas.html index 652d9a5..a5838a4 100644 --- a/damas.html +++ b/damas.html @@ -4,16 +4,30 @@ Damas! + -
+

Damas!

+ +
Jugadores
+ + + + + + + -
Turno blancas!
+
+ diff --git a/damas.js b/damas.js index 68a1b6c..7ac09a7 100644 --- a/damas.js +++ b/damas.js @@ -38,7 +38,79 @@ let segundaCaptura=false; //Esta función se va a encargar de crear la tabla del juego //con botones, también de setear la matriz "tablero" -crearTablero(); +//crearTablero(); +function agregar(){ + + //crea objetos correspondientes a elementos del DOM + selectX = document.getElementById("selectX"); + selectO = document.getElementById("selectO"); + option1 = document.createElement('option'); + option2 = document.createElement('option'); + jugadorInput = document.getElementById("jugadorInput"); + + //Comprueba que el input del jugador no esté vacío + if(jugadorInput.value==""){ + alert("Debe introducir un nombre!"); + return; + } + + //Setea el valor del option con el valor del input + option1.value=jugadorInput.value + option1.innerHTML=jugadorInput.value; + option2.value=jugadorInput.value + option2.innerHTML=jugadorInput.value; + + //Para agregar el valor del input al select + selectX.appendChild(option1); + selectO.appendChild(option2); + + //Muestra el