Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are trying it getElementsByName() should be document.getElementsByName() like this:</p> <pre><code>var volts = document.getElementsByName("voltDrop_volts")[0].value; var acdc = document.getElementsByName("voltDrop_acdc")[0].value; var amps = document.getElementsByName("voltDrop_amps")[0].value; var length = document.getElementsByName("voltDrop_ft")[0].value; var awg = document.getElementsByName("voltDrop_awg")[0].value; </code></pre> <p>Tested:</p> <pre><code>&lt;body&gt; &lt;h1&gt;Voltage Drop Calculator Tool&lt;/h1&gt; &lt;form id=form1&gt; &lt;div class="calculator-wrapper" id="voltageDropCalc" style="margin: 10px 0 20px 20px; padding: 15px;"&gt;&lt;!-- BEGIN Calc wrapper --&gt; &lt;p&gt;1. Initial Voltage&lt;/p&gt; &lt;select name="voltDrop_volts" size="1" style="padding: 3px;"&gt; &lt;option value="0"&gt;Choose...&lt;/option&gt; &lt;option value="12"&gt;12 Volt&lt;/option&gt; &lt;option value="24"&gt;24 Volt&lt;/option&gt; &lt;/select&gt; &lt;p&gt;2. AC / DC&lt;/p&gt; &lt;select class="sized" name="voltDrop_acdc" size="1" style="padding: 3px;"&gt; &lt;option selected="selected" value="dc"&gt;DC&lt;/option&gt; &lt;option value="ac"&gt;AC&lt;/option&gt; &lt;/select&gt; &lt;p class="field-label field-label-right"&gt;3. Current (Amps)&lt;/p&gt; &lt;input align="bottom" class="sized" name="voltDrop_amps" size="15" style="padding: 3px;" type="text" /&gt; &lt;p class="field-label field-label-right"&gt;4. Cable Length (ft)&lt;/p&gt; &lt;input align="bottom" class="sized" name="voltDrop_ft" size="15" style="padding: 3px;" type="text" /&gt; &lt;p class="field-label field-label-right"&gt;5. Cable Gauge (AWG)&lt;/p&gt; &lt;input align="bottom" class="sized" name="voltDrop_awg" size="15" style="padding: 3px;" type="text" /&gt; &lt;p&gt;&lt;a href="#" id="voltageDropSubmit" style="text-decoration: none;" onclick="printAnswer()"&gt;&lt;button type="button"&gt;Calculate&lt;/button&gt;&lt;/a&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a class="clearBtn" href="#" style="text-decoration: none;"&gt;&lt;button type="button" onclick="formReset()"&gt;Cancel&lt;/button&gt;&lt;/a&gt;&lt;/p&gt; &lt;div class="results-box"&gt; &lt;p id="theAnswer"style="margin: 10px 0;"&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/form&gt; &lt;p&gt;Note: Industry standard is a voltage drop of no greater than 10%.&lt;/p&gt; &lt;div class="errorMsg"&gt;&lt;/div&gt; &lt;!-- displays error messages to user --&gt; &lt;/div&gt; &lt;!-- END Calc wrapper --&gt; &lt;script type="text/javascript"&gt; var volts = 0; var acdc = 0; var amps = 0; var length = 0; var awg = 0; var amp = 0; volts = document.getElementsByName("voltDrop_volts")[0].value; acdc = document.getElementsByName("voltDrop_acdc")[0].value; amps = document.getElementsByName("voltDrop_amps")[0].value; length = document.getElementsByName("voltDrop_ft")[0].value; awg = document.getElementsByName("voltDrop_awg")[0].value; var ohm = 0; if (awg === 36) { ohm = 371.0; } else if (awg === 34) { ohm = 237.0; } else if (awg === 32) { ohm = 164.0; } else if (awg === 30) { ohm = 103.0; } else if (awg === 28) { ohm = 64.9; } else if (awg === 26) { ohm = 37.3; } else if (awg === 24) { ohm = 23.3; } else if (awg === 22) { ohm = 14.7; } else if (awg === 20) { ohm = 10.0; } else if (awg === 18) { ohm = 6.4; } else if (awg === 16) { ohm = 4.0; } else if (awg === 14) { ohm = 2.5; } else if (awg === 12) { ohm = 1.6; } else if (awg === 10) { ohm = 1.1; } else if (awg === 8) { ohm = .62; } else if (awg === 6) { ohm = .40; } else if (awg === 4) { ohm = .24; } else if (awg === 2) { ohm = .16; } else if (awg === 1) { ohm = .13; } else if (awg === '1/0') { ohm = .096; } else if (awg === '2/0') { ohm = .077; } else if (awg === '3/0') { ohm = .062; } else if (awg === '4/0') { ohm = .049; } else { msg = "Error"; } var vDrop = ((ohm * 2) * (length / 1000) * amp); var vFinal = (volts - vDrop); function formReset() { document.getElementById("form1").reset(); } function printAnswer() { document.getElementById("theAnswer").innerHTML = vFinal; } &lt;/script&gt; &lt;/body&gt; </code></pre> <p>Note that you're using "amp" when you are setting the value to the "amps"</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload