title: Post value of button in node.js
body: <p>I have a form that submits a query, which will eventually be executed in MySQL</p>
  
  <p>however, I have an issue posting the text value of a button. I have a button wit a dropdown that allows the mode of query, and I need to be able to access this in my node.js post method. when trying to access the text or value of the button with id "searchmethod" it crashes saying that the button is undefined, however, my textbox returns post just fine.</p>
  
  <p>EDIT:
  TypeError: Cannot read property 'value' of undefined at Object.handle (/root/Folder/app/routes.js:15:50) at next_layer (/root/Folder/node_modules/express/lib/router/route.js:103:13) at Route.dispatch (/root/Folder/node_modules/express/lib/router/route.js:107:5) at c (/root/Folder/node_modules/express/lib/router/index.js:195:24) at Function.proto.process_params (/root/Folder/node_modules/express/lib/router/index.js:251:12) at next (/root/Folder/node_modules/express/lib/router/index.js:189:19) at next_layer (/root/Folder/node_modules/express/lib/router/route.js:77:14) at next_layer (/root/Folder/node_modules/express/lib/router/route.js:81:14) at next_layer (/root/Folder/node_modules/express/lib/router/route.js:81:14) at Route.dispatch (/root/Folder/node_modules/express/lib/router/route.js:107:5)</p>
  
  <p>HTML for the button/Form</p>
  
  <pre><code>&lt;form method="post" action="/" class="box"&gt;
              &lt;h3 style="color:#5F5F5F"&gt;Inventory Item Lookup&lt;/h3&gt;
              &lt;div class="input-group dropdown"&gt;
                  &lt;div class="input-group-btn"&gt;
                      &lt;button name="searchmethod" id="search-button" type="button" class="btn btn-default"&gt;Name&lt;/button&gt;
                      &lt;button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"&gt;
                          &lt;span class="caret"&gt;&lt;/span&gt;
                          &lt;span class="sr-only"&gt;Toggle Dropdown&lt;/span&gt;
                      &lt;/button&gt;
                      &lt;ul class="dropdown-menu" role="menu"&gt;
                          &lt;li class="drop-list-item"&gt;&lt;a href="#"&gt;Name&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="drop-list-item"&gt;&lt;a href="#"&gt;Manufacturer&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="drop-list-item"&gt;&lt;a href="#"&gt;Description&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="drop-list-item"&gt;&lt;a href="#"&gt;Location&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="divider"&gt;&lt;/li&gt;
                          &lt;li class="drop-list-item"&gt;&lt;a href="#"&gt;Smart Search&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
                  &lt;input type="text" name="searchstring" class="form-control" style="z-index: auto"&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>js code for post</p>
  
  <pre><code>app.post('/', function(req, res) {
      res.send('Search Function: ' + req.body.searchmethod.value + ":" + req.body.searchstring); // this will eventually cause a return from SQL
      console.log("Search Function: " + req.body.searchmethod.value + ":" +  req.body.searchstring);
  });
  </code></pre>
  
  <p>req.body.searchstring works fine. req.body.searchmethod.value fails because "searchmethod" is undefined. searchmethod.text also fails. </p>