kapazitaet_von_keramikkondensatoren.js 965 B

1234567891011121314151617181920212223
  1. function calculateCapacity()
  2. {
  3. document.getElementById("output_capacity_pf").innerHTML = "0";
  4. document.getElementById("output_capacity_nf").innerHTML = "0";
  5. document.getElementById("output_capacity_uf").innerHTML = "0";
  6. document.getElementById("input_number").style.backgroundColor = "red";
  7. var input = document.getElementById("input_number").value;
  8. if (input.length === 3)
  9. {
  10. var exp = parseInt(input[2]);
  11. var num = parseInt(input.substr(0, 2));
  12. var capacity = num * Math.pow(10, exp);
  13. if ( ! isNaN(capacity) )
  14. {
  15. document.getElementById("output_capacity_pf").innerHTML = capacity.toLocaleString("de");
  16. document.getElementById("output_capacity_nf").innerHTML = (capacity / 1000.0).toLocaleString("de");
  17. document.getElementById("output_capacity_uf").innerHTML = (capacity / 1000000.0).toLocaleString("de");
  18. document.getElementById("input_number").style.backgroundColor = "green";
  19. }
  20. }
  21. }