title: Getting value from an input field Javascript
body: <p>I have a form which fills the input fields on page load off of MySQL server, but when I try to assign it's value to a JavaScript variable, it crashes.</p>
  
  <p>Here is JS;</p>
  
  <pre><code> function getTotal(e)
    {
      total = myform2.1.value;
  
    }
  </code></pre>
  
  <p>It just crashes and here is my html/php;</p>
  
  <pre><code>    &lt;?php
  include('connect.php');
  $id=$_GET['id'];
  $result = $db-&gt;prepare("SELECT * FROM zones WHERE id= 1");
  $result-&gt;bindParam('1', $id);
  $result-&gt;execute();
  for($i=0; $row = $result-&gt;fetch(); $i++){
  ?&gt;
  
  &lt;form action="edit.php" method="POST" class="elegant-aero" name="myform2"&gt;
  &lt;input type="hidden" name="memids" value="&lt;?php echo $id; ?&gt;" /&gt;
  &lt;br&gt;
  &lt;input type="text" name="1" value="&lt;?php echo $row['1']; ?&gt;" /&gt;&lt;br&gt;
  &lt;br&gt;
  &lt;input type="text" name="2" value="&lt;?php echo $row['2']; ?&gt;" /&gt;&lt;br&gt;
  &lt;br&gt;
  &lt;input type="text" name="3" value="&lt;?php echo $row['3']; ?&gt;" /&gt;&lt;br&gt;
  &lt;input type="button" value="za" id="secret" onclick="getTotal(this)"/&gt;
  &lt;/form&gt;
  &lt;?php
      }
  ?&gt;
  </code></pre>
  
  <p>Basically I fill the HTML input fields with data from MySQL but the JavaScript variable <code>total</code> didn't couldn't retrieve the value, although the HTML input field gets the value just fine from the MySQL server via PHP, any thoughts??</p>