title: Node.js - How to send data from html to express
body: <p>this is form example in html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;title&gt;CSS3 Contact Form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="contact"&gt;
      &lt;h1&gt;Send an email&lt;/h1&gt;
      &lt;form action="/myaction" method="post"&gt;
          &lt;fieldset&gt;
              &lt;label for="name"&gt;Name:&lt;/label&gt;
              &lt;input type="text" id="name" name="name" placeholder="Enter your full name" /&gt;
  
              &lt;label for="email"&gt;Email:&lt;/label&gt;
              &lt;input type="email" id="email" placeholder="Enter your email address" /&gt;
  
              &lt;label for="message"&gt;Message:&lt;/label&gt;
              &lt;textarea id="message" placeholder="What's on your mind?"&gt;&lt;/textarea&gt;
  
              &lt;input type="submit" value="Send message" /&gt;
  
          &lt;/fieldset&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is node.js function that run on the server:</p>
  
  <pre><code>var sys = require('sys'),
      http = require('http');
      http.createServer(function (req, res) {
              switch (req.url) 
                  case '/myaction':
                          res.end(?????);
                      break;
              }
      }).listen(8080);
  sys.puts('Server running at http://127.0.0.1:8080/');
  </code></pre>
  
  <p>I have 2 questions:</p>
  
  <ol>
  <li>How can I call <code>myaction</code> function in the node.js from the html page? Because the html file runs on port 80 and node.js on 8080 (when I try to move the node.js to port 80 it writes "// Unhandled 'error' event")</li>
  <li>In the node.js function where I put "?????" how can I get data from the html form.
  When I type req.html.body.name I don't get the data...</li>
  </ol>