{"id":1363,"date":"2022-08-30T15:15:54","date_gmt":"2022-08-30T15:15:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/13\/why-is-document-formsmyforminput-value-return-undefined-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:54","modified_gmt":"2022-08-30T15:15:54","slug":"why-is-document-formsmyforminput-value-return-undefined-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/why-is-document-formsmyforminput-value-return-undefined-collection-of-common-programming-errors\/","title":{"rendered":"Why is document.forms[&ldquo;myform&rdquo;][&ldquo;input&rdquo;].value return undefined-Collection of common programming errors"},"content":{"rendered":"<p>So here&#8217;s me trying to make a HTML5 version of the Tone Matrix program. So here&#8217;s the problem, I have the user enter how long they want their song to be and then to make sure they entered a number, so i used<\/p>\n<pre><code>  function initiate(){\n  var min = document.forms[\"initiator\"][\"min\"].value;\n  var sec = document.forms[\"initiator\"][\"sec\"].value;\n  \/\/ some logic\n  return false;}\n<\/code><\/pre>\n<p>to check to see if the stuff they entered is indeed a number but when I try to do this, the browser spits back &#8220;Uncaught TypeError: Cannot read property &#8216;min&#8217; of undefined&#8221; here&#8217;s what&#8217;s in my DOM.<\/p>\n<pre><code>\nYour song will be (at most):  minutes and  seconds long.<br \/>\n\n<br \/>\n<\/code><\/pre>\n<p>i have also placed the thing onto a hosting service located here http:\/\/www.sfu.ca\/~zla49\/MMC\/ so ya Thanks \ud83d\ude42<\/p>\n<ol>\n<li>\n<p>You don&#8217;t have a <code>name<\/code> on your form.<\/p>\n<p>It should look like<\/p>\n<p>What may be more beneficial, if you don&#8217;t want to name the form is to pass the form object as a parameter:<\/p>\n<pre><code>function initiate(form){\n  var min = form[\"min\"].value;\n  var sec = form[\"sec\"].value;\n  \/\/ some logic\n  return false;\n}\n\n\n\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-13 09:49:57. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>So here&#8217;s me trying to make a HTML5 version of the Tone Matrix program. So here&#8217;s the problem, I have the user enter how long they want their song to be and then to make sure they entered a number, so i used function initiate(){ var min = document.forms[&#8220;initiator&#8221;][&#8220;min&#8221;].value; var sec = document.forms[&#8220;initiator&#8221;][&#8220;sec&#8221;].value; \/\/ some [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1363","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1363"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1363\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}