Note that there are some explanatory texts on larger screens.

plurals
  1. POJS: Uncaught TypeError: object is not a function (onclick)
    text
    copied!<p><strong>Edit:</strong> <a href="http://jsfiddle.net/XpmZG/">Here's a JSfiddle</a></p> <p><strong>Edit2:</strong> The error is on this line: <code>&lt;input type="button" value="totalbandwidthresult" onclick="javascript:totalbandwidth();"&gt;</code> </p> <p>Trying to have a button perform a calculation. The required variables are below, as well as the HTML where </p> <p>I am getting an error onclick: <code>Uncaught TypeError: object is not a function index.html:71 onclick</code></p> <p>Here is my Javascript</p> <pre><code>function totalbandwidth() { var fps=Number(document.calculator.fps.value); var bitrate=Number(document.calculator.bitrate.value); var numberofcameras = Number(document.calculator.numberofcameras.value); var encoding = document.calculator.encoding.value; if (encoding = "mjpeg") { storage = bitrate*fps; } else { storage = bitrate; } totalbandwidth = (numberofcameras * storage) / 1000; document.calculator.totalbandwidthresult.value = totalbandwidth; } </code></pre> <p>The HTML:</p> <pre><code>&lt;form name="calculator" class="formtable"&gt; &lt;div class="formrow"&gt;&lt;label for="rcname"&gt;RC Name&lt;/label&gt; &lt;input type="text" name="rcname"&gt;&lt;/div&gt; &lt;div class="formrow"&gt;&lt;label for="fps"&gt;FPS&lt;/label&gt; &lt;input type="text" name="fps"&gt; &lt;/div&gt; &lt;div class="formrow"&gt;&lt;label for="bitrate"&gt;Bitrate&lt;/label&gt; &lt;input type="text" name="bitrate"&gt; &lt;/div&gt; &lt;div class="formrow"&gt;&lt;label for="numberofcameras"&gt;Number of Cameras&lt;/label&gt; &lt;input type="text" name="numberofcameras"&gt; &lt;/div&gt; &lt;div class="formrow"&gt;&lt;label for="encoding"&gt;Encoding&lt;/label&gt; &lt;select name="encoding" id="encodingoptions"&gt; &lt;option value="h264"&gt;H.264&lt;/option&gt; &lt;option value="mjpeg"&gt;MJPEG&lt;/option&gt; &lt;option value="mpeg4"&gt;MPEG4&lt;/option&gt; &lt;/select&gt;&lt;/div&gt; Total Storage: &lt;input type="text" name="totalstorage"&gt; Total Bandwidth: &lt;input type="text" name="totalbandwidth"&gt; &lt;input type="button" value="totalbandwidthresult" onclick="javascript:totalbandwidth();"&gt; </code></pre> <p> </p> <p>Basically - it seems that there may be something wrong with the syntax I used in the JS - but I'm not sure.</p>
 

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