how to retrieve localStorage data? #473
DesarrollosDimpulsoX
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i got this code
`// cuando clickeas en el boton crear contacto, aparece el div para agregar contactos a la agenda
function myToggle () {
$(document).ready(function(){
var element = document.getElementById("hide-show");
$(".toggle").click(function(){
$(".agenda_container").hide();
$(element).fadeIn(500);
});
$(".btn-addcontacts").click(function() {
$(element).fadeOut(500);
$(".agenda_container").show();
});
});
}
var count=0;
// función para agregar valores a la tabla
function agregarValores () {
// Capturando Variables
const nombre = document.getElementById("nombre").value;
const apellidos = document.getElementById("apellidos").value;
const correo = document.getElementById("correo").value;
const celular = document.getElementById("celular").value;
}
//Función para eliminar un valor de la tabla
function eliminarValor (id) {
var row = document.getElementById(id);
row.parentNode.removeChild(row, id);
}
//Función que crea el boton de eliminar
//Tiene que recibir el id a eliminar
function crearButton (id) {
var button = document.createElement("input");
var attrType = document.createAttribute('type');
attrType.value = "button";
var attrValue = document.createAttribute('value');
attrValue.value = "Eliminar";
var attrOnclick = document.createAttribute('onclick');
attrOnclick.value = "eliminarValor("+count+");";
}
`
with this snippet i save the data as an array, i try many ways found in different blogs but didnt help
snippet : localStorage.setItem(nombre, JSON.stringify(datos));
could somebody help me?
here is a snippet from the html
<div class="agenda_container"> <input class="toggle" id="inlinetoggle" type="button" value="Crear nuevo" onclick="myToggle ()"> <table id="miTabla"> <thead> <tr> <td class="card-user"></td> <td class="card-user">Nombre</td> <td class="card-user">Apellido</td> <td class="card-user">Email</td> <td class="card-user">Celular</td> <td class="card-user"></td> </tr> </thead> <tbody id="contactos"> </tbody> </table> </div> <div class="addcontact-form" id="hide-show"> <h2 id="h2addcontact">Crear Contacto</h2> <form> <div class="addcontactinput"> <label id="label-addcontacts" for="nombre">Nombre:</label> <input type="name" class="name" placeholder="Nombre/s" name="name" required id="nombre"> </div> <div class="addcontactinput"> <label id="label-addcontacts" for="apellidos">Apellido:</label> <input type="text" class="name" placeholder="Apellido/s" name="surname" required id="apellidos"> </div> <div class="addcontactinput"> <label id="label-addcontacts" for="correo">Correo:</label> <input type="email" class="mail" placeholder="Correo Electrónico" name="email" required id="correo"> </div> <div class="addcontactinput"> <label id="label-addcontacts" for="celular">Celular:</label> <input type="tel" class="celular" placeholder="Número Celular" name="celular" required id="celular"> </div> <p id="center-input"> <input type="button" id="btn-addcontacts" class="btn-addcontacts" style="width: fit-content;" onclick="agregarValores();" value="Agregar"> </p> </form> </div>
Beta Was this translation helpful? Give feedback.
All reactions