title: JavaScript throws a read property 'submit' error
body: <p>I got this error:</p>
  <blockquote>
  <p>?shiftType=4:49 Uncaught TypeError: Cannot read property 'submit' of undefined
  at success (?type=4:49)
  success @ ?type=4:49</p>
  </blockquote>
  <p>This is my JavaScript</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script type=&quot;text/javascript&quot;&gt;
      &lt;!--      
      function addLatlng()
      { 
          var options = {
              enableHighAccuracy: true,
              timeout: 5000,
              maximumAge: 0
          };
  
          function success(pos) 
          {
              
  
              var crd = pos.coords;
              
              console.log(crd.latitude);
              console.log('Your current position is:');
              console.log(`Latitude : ${crd.latitude}`);
              console.log(`Longitude: ${crd.longitude}`);
              console.log(`More or less ${crd.accuracy} meters.`);
              document.getElementById('latlng').value = crd.latitude + &quot;-&quot; + crd.longitude;
              document.openShiftForm.submit();
          };
  
          function error(err) {
              console.warn(`ERROR(${err.code}): ${err.message}`);
              document.getElementById('latlng').value = &quot;ERROR&quot; + &quot;-&quot; + err.message;
              document.openShiftForm.submit();
          };
  
          navigator.geolocation.getCurrentPosition(success, error, options);
      
      }
      // --&gt;
  &lt;/script&gt;
  </code></pre>
  <p>And this is the HTML part:</p>
  <pre><code>echo '&lt;form action=&quot;&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;openShiftForm&quot;&gt;';
  echo '&lt;input type=&quot;hidden&quot; id=&quot;latlng&quot; name=&quot;latlng&quot; value=&quot;&quot;&gt;';
  echo '&lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;openShift&quot;&gt;';
  echo '&lt;button type=&quot;button&quot;  onclick=&quot;addLatlng()&quot; class=&quot;btn btn-danger btn-lg&quot; name=&quot;openShift&quot; value=&quot;1&quot;&gt;'.$shiftTypeArray[intval($_SESSION['openShiftType'])]['name'].' open shift&lt;/button&gt;';
  echo '&lt;/form&gt;'; 
  </code></pre>
  <p>Can anyone help?</p>