Agregar estudios a postulantes

parent 6c7fe450
...@@ -90,3 +90,56 @@ form.addEventListener("submit",(evt)=>{ ...@@ -90,3 +90,56 @@ form.addEventListener("submit",(evt)=>{
}); });
evt.preventDefault(); evt.preventDefault();
} ); } );
//Metodos para Estudios
function agregarFieldEstudio(){
//recoger del form
const pairs = {};
const formest = document.querySelector("[name=estudio-form");
const formData = new FormData(formest);
for (const [name, value] of formData){
pairs[name] = value
}
estudios[cont_estudios] = pairs;
formest.reset();
//imprimir lista actualizada
const div = document.querySelector("#estudios")
const div1 = document.createElement('div');
let content='<ul>'
for (let index = 0; index < estudios.length; index++) {
const est = estudios[index];
if(est==null) continue;
content += `
<li id="est-${index}">
${est.institucion}
<button type="button" onclick="eliminarEstudio(event)">Eliminar</button>
</li>
`
}
content += "</ul>"
div1.innerHTML = content
div.innerHTML = '';
div.appendChild(div1);
cont_estudios++;
}
function eliminarEstudio(event) {
//eliminar del array
estudios[event.target.parentElement.id.split("-")[1]]=null
//eliminar en html
event.target.parentElement.remove()
}
...@@ -67,18 +67,21 @@ ...@@ -67,18 +67,21 @@
<label for="modalidad" class="form-label">Modalidad</label> <label for="modalidad" class="form-label">Modalidad</label>
<input type="text" class="form-control " name="modalidad" id="modalidad" > <input type="text" class="form-control " name="modalidad" id="modalidad" >
</div> </div>
<br>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#experienciaForm"> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#experienciaForm">
Agregar Experiencia Agregar Experiencia
</button> </button>
<div id="experiencias"> <div id="experiencias"></div>
<br>
</div> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#estudioForm">
Agregar Estudios
</button>
<br><br>
<div id="estudios"></div>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
</form> </form>
<!--Modal de Experiencia-->
<div class="modal fade" id="experienciaForm" tabindex="-1" role="dialog" aria-labelledby="experienciaForm" aria-hidden="true"> <div class="modal fade" id="experienciaForm" tabindex="-1" role="dialog" aria-labelledby="experienciaForm" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
...@@ -110,6 +113,47 @@ ...@@ -110,6 +113,47 @@
</div> </div>
</div> </div>
<!--Modal de Estudios-->
<div class="modal fade" id="estudioForm" tabindex="-1" role="dialog" aria-labelledby="estudioForm" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Estudios</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form name="estudio-form">
<label for="tipoDeEstudio" class="form-label">Tipo De Estudio</label>
<input type="text" class="form-control " name="tipoDeEstudio" id="tipoDeEstudio">
<label for="institucion" class="form-label">Institucion</label>
<input type="text" class="form-control " name="institucion" id="institucion">
<label for="fechaDesde" class="form-label">Fecha Desde</label>
<input type="date" class="form-control " name="fechaDesde" id="fechaDesde" >
<label for="fechaHasta" class="form-label">Fecha Hasta</label>
<input type="date" class="form-control " name="fechaHasta" id="fechaHasta" >
<label for="referencias" class="form-label">Referencias</label>
<input type="text" class="form-control " name="referencias" id="referencias" >
<label for="titulo" class="form-label">Titulo</label>
<input type="text" class="form-control " name="titulo" id="titulo" >
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
<button type="button" class="btn btn-primary" onclick="agregarFieldEstudio()" data-dismiss="modal">Agregar</button>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript; choose one of the two! --> <!-- Optional JavaScript; choose one of the two! -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment