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

129
Views
Pasar valor de entrada a otra entrada sin onclick

Tengo un código de trabajo para pasar el valor de una identificación a otra, pero para hacerlo necesito un botón para pasarlo al hacer clic. Quiero pasar el valor sin un botón directamente a la otra entrada. Mientras investigaba, acabo de ver soluciones onclick... ¿Hay alguna otra forma o estoy atascado con esta opción?

Mi código:

 window.onload = function() { document.getElementById('button').onclick = function() { document.getElementById('email2').value = document.getElementById('email').value; document.getElementById('firma2').value = document.getElementById('firma').value; document.getElementById('name2').value = document.getElementById('name').value; document.getElementById('nummer2').value = document.getElementById('nummer').value; } };
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Pruebe esta solución:

 const textInput = document.querySelector('#text'); const checkboxInputs = document.querySelectorAll('[id^=checkbox]'); const secondInput = document.querySelector('#second'); const thirdInput = document.querySelector('#third'); textInput.addEventListener('input', (e) => { secondInput.value = e.target.value; }) textInput.addEventListener('change', (e) => { thirdInput.value = e.target.value; }) const checkboxesSet = new Set(); checkboxInputs.forEach(checkboxInput => checkboxInput.addEventListener('change', (e) => { const label = document.querySelector(`label[for=${e.target.id}]`).innerText; checkboxesSet[e.target.checked ? 'add' : 'delete'](label); const text = [...checkboxesSet].join(', '); secondInput.value = text; thirdInput.value = text; }) )
 <label for="text">Text input</label> <input id="text"> <br/> <label for="checkbox1">Checkbox input 1</label> <input id="checkbox1" type="checkbox"> <br/> <label for="checkbox2">Checkbox input 2</label> <input id="checkbox2" type="checkbox"> <br/> <label for="second">While typing</label> <input id="second"> <br/> <label for="third">At the end</label> <input id="third">

about 4 years ago · Juan Pablo Isaza Report

0

Podría considerar usar onchange en lugar de onclick.

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!