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

258
Views
¿Cómo programar un convertidor/calculadora de bits con esta tabla usando javascript y este código html?

Cómo programar un convertidor/calculadora de bit byte con esta tabla usando javascript y este código html

 <table> <tbody><tr><td class="unit">Bit (b):</td><td><input type="number"></td></tr> <tr><td class="unit">Byte (B):</td><td><input type="number"></td></tr> <tr><td class="unit">Kilobyte (kB):</td><td><input type="number"></td></tr> <tr><td class="unit">Megabyte (MB):</td><td><input type="number" ></td></tr> <tr><td class="unit">Gigabyte (GB):</td><td><input type="number" ></td></tr> <tr><td class="unit">Terabyte (TB):</td><td><input type="number"></td></tr> <tr><td class="unit">Petabyte (PB):</td><td><input type="number" ></td></tr> <tr><td class="unit">Exabyte (EB):</td><td><input type="number" ></td></tr> </tbody></table><br> <input class="press" type="button" value="Berechnen">&nbsp;&nbsp; <input class="press" type="reset" value="Löschen"> </form> <br><br> <br>*
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes intentar algo como esto:

 const units = [ 8, 1, 1024, 1048576, 1073741824, 1099511627776, 1125899906842624, 1152921504606846976, ] let table = document.getElementById("myTable"); function changeHandler() { let input = this.firstChild.value let idx = this.firstChild.id let bytes = (idx == 0) ? input / units[idx] : input * units[idx] units.forEach((item, idx) => { let val = (idx == 0) ? bytes * units[idx] : bytes / units[idx] table.rows[idx].cells[1].firstChild.value = val }) } document.querySelectorAll("#myTable td") .forEach(e => e.addEventListener("change", changeHandler));
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Test</title> </head> <body> <table id="myTable"> <tbody> <tr><td class="unit">Bit (b):</td><td><input id="0" type="number"></td></tr> <tr><td class="unit">Byte (B):</td><td><input id="1" type="number"></td></tr> <tr><td class="unit">Kilobyte (kB):</td><td><input id="2" type="number"></td></tr> <tr><td class="unit">Megabyte (MB):</td><td><input id="3" type="number" ></td></tr> <tr><td class="unit">Gigabyte (GB):</td><td><input id="4" type="number" ></td></tr> <tr><td class="unit">Terabyte (TB):</td><td><input id="5" type="number"></td></tr> <tr><td class="unit">Petabyte (PB):</td><td><input id="6" type="number" ></td></tr> <tr><td class="unit">Exabyte (EB):</td><td><input id="7" type="number" ></td></tr> </tbody> </table> </body> </html>

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!