Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Establecer el valor de los formularios de una cookie en la carga de la página, pero el valor desaparece tan pronto como hago clic en una entrada

Estoy tratando de guardar los datos del formulario como una cookie y luego completar un formulario si el usuario tiene una cookie coincidente en la carga de la página. Parece funcionar según lo previsto, pero luego, cuando hago clic en cualquier entrada en el formulario, hace que se borren los valores establecidos por javascript.

Mi JS:

 // when the user click on the hs-submit button, serialize the form data and save it in a cookie $('.hs-submit').click(function(e){ e.preventDefault(); var formID = $(this).attr('data-form'); var form = $(`.form-${formID}`).find('form'); var formData = form.serializeArray(); // convert the form to a string var data = JSON.stringify(formData); $.cookie(`hs-form-${formID}`, data, { expires: 7, path: '/' }); }); // when the user loads the page, if they have a cookie for the form, populate the form if($.cookie('hs-form-1')){ var formData = $.cookie('hs-form-1'); // convert the formData to parsedData var parsedData = JSON.parse(formData); var form = $(`.form-1`).find('form'); $.each(parsedData, function(i, field){ form.find(`[name="${field.name}"]`).val(field.value); }); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!