title: How to detect user input into a form on a webpage
body: <p>I am trying to detect if the user enters something on a webpage hosted by golang but every time the user clicks the button and submits the form it just redirects to a different page (I am hosting on localhost:8080 and it redirects to localhost:8080/text). I am pretty sure this is because the form action is set to "/text" but if I remove that the golang handlefunc is never run. Here is what I have so far:</p>
  
  <pre><code>package main
  
  import (
    "log"
    "net/http"
    "fmt"
  )
  
  func main()() {
    //runs server
    fs := http.FileServer(http.Dir("./"))
    http.Handle("/", fs)
    log.Println("Listening...")
    http.ListenAndServe(":8080", nil)
    //detects user input and calls function
    http.HandleFunc("/text", textGetter)
  }
  
  func textGetter (w http.ResponseWriter, r *http.Request) () {
    r.ParseForm()
    text := r.PostFormValue("text")
    fmt.Fprintf(w, "this: %s", text)
    fmt.Print(" was written in the text box")
  }
  </code></pre>
  
  <p>and this html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;hello&lt;/title&gt;
      &lt;link rel="stylesheet" href="./stylesheet.css"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;Write something bellow&lt;/h1&gt;
      &lt;form class="userText" action="/text" method="post"&gt;
        &lt;input type="text" name="textbox" id="textBox" value="" placeholder="type something here"&gt;
        &lt;input type="submit" value="text" name="button" id="button" onclick="thank(message.value)"&gt;
      &lt;/form&gt;
      &lt;script type="text/javascript" src="./script.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can someone tell me what's wrong?</p>