mirror of
https://github.com/CristianCruz0309/proyectos-curso-javascript.git
synced 2026-08-15 02:50:10 +00:00
Proyectos (DIA 1 - 13)
Realizados gracias al curso "JAVASCRIPT TOTAL"
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Empleados</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Registro de Empleados</h2>
|
||||
<hr>
|
||||
<p>Legajo</p>
|
||||
<input type="text" id="txtLegajo">
|
||||
<p>Nombre</p>
|
||||
<input type="text" id="txtNombre">
|
||||
<p>Apellido</p>
|
||||
<input type="text" id="txtApellido">
|
||||
<p>Fecha de nacimiento</p>
|
||||
<input type="text" id="txtNacimiento">
|
||||
<p>Cargo</p>
|
||||
<input type="text" id="txtCargo">
|
||||
<br>
|
||||
<br>
|
||||
<button onclick="agregarEmpleado()">Cargar empleado</button>
|
||||
<br>
|
||||
<br>
|
||||
<button onclick="mostrarEmpleados()">Mostrar empleados</button>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,42 @@
|
||||
let empleados = [];
|
||||
|
||||
function Empleado(legajo, nombre, apellido, nacimiento, cargo) {
|
||||
this.legajo = legajo;
|
||||
this.nombre = nombre;
|
||||
this.apellido = apellido;
|
||||
this.nacimiento= nacimiento;
|
||||
this.cargo = cargo;
|
||||
}
|
||||
|
||||
function agregarEmpleado() {
|
||||
let legajo = document.getElementById("txtLegajo").value;
|
||||
let nombre = document.getElementById("txtNombre").value;
|
||||
let apellido = document.getElementById("txtApellido").value;
|
||||
let nacimiento = document.getElementById("txtNacimiento").value;
|
||||
let cargo = document.getElementById("txtCargo").value;
|
||||
|
||||
let empleado = new Empleado(legajo, nombre, apellido, nacimiento, cargo)
|
||||
empleados.push(empleado)
|
||||
|
||||
alert("Empleado ha sido agregado!");
|
||||
limpiarCampos();
|
||||
}
|
||||
|
||||
function mostrarEmpleados() {
|
||||
let listado = '';
|
||||
for(empleado of empleados) {
|
||||
for(let prop in empleado) {
|
||||
listado = listado + prop.toUpperCase() + ": " + empleado[prop] + ", ";
|
||||
}
|
||||
listado = listado + "\n";
|
||||
}
|
||||
alert(listado);
|
||||
}
|
||||
|
||||
function limpiarCampos() {
|
||||
document.getElementById("txtLegajo").value = "";
|
||||
document.getElementById("txtNombre").value = "";
|
||||
document.getElementById("txtApellido").value = "";
|
||||
document.getElementById("txtNacimiento").value = "";
|
||||
document.getElementById("txtCargo").value = "";
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
body {
|
||||
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
|
||||
margin-left: 2rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: brown;
|
||||
}
|
||||
|
||||
button {
|
||||
height: 30px;
|
||||
width: 158px;
|
||||
background-color: darkblue;
|
||||
color: white;
|
||||
}
|
||||
|
||||
input {
|
||||
height: 20px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
Reference in New Issue
Block a user