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
Shelf life of numbers in inputs

I have friends of the multi-page application. On one page there is a calculator mode in which three actually have a text box. And in the first two, you enter values, and then in the third, you enter a number. Now if I enter numbers and move from the page, the numbers will be deleted. But I do not want this to happen and I want the numbers to remain in the text boxes

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use

let names=['input1','input2','input3'];
function parseCookie(text) {
 if(text.length) {//if the length of the text is not 0
 let values={};
 for(let i=0;i<names.length;i++) {
  let namePos=text.indexOf(names[i]+'=')+names[i].length+1;
  values[names[i]]=text.slice(namePos,text.indexOf(';',namePos))
   }
 return values} else {return false}

  }
let inputs=document.querySelectorAll('input'); //get the input areas
let cookies=parseCookie(document.cookie)
if(cookies) {
 for(let i=0;i<names.length;i++) {
  inputs[i].value=cookies[names[i]];
  inputs[i].addEventListener('input',function() {document.cookie=names[i]+"="+document.getElementById(names[i]).value}++';expires=Thu, 18 Dec 3000 12:00:00 UTC')
   }
  }
about 4 years ago · Juan Pablo Isaza Report
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!