--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
func main() {
http.HandleFunc("/sbcs", sbcs)
http.HandleFunc("/systemnames", systemnames)
http.HandleFunc("/home", home)
log.Fatal(http.ListenAndServe("99.119.228.55:8080", nil))
}
func systemnames(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
fmt.Println("Getting ready to serve all systems")
var sbcNames, _ = sbcutilities.GetAllSystemNames()
var err error = apopPage.Execute(w, Page{
Title: "System Names",
Content: sbcNames,
})
if err != nil {
fmt.Println(err)
}
} else {
fmt.Println("Getting ready to print the system details")
r.ParseForm()
systemname := fmt.Sprint(r.Form["systemname"])
var sbcs, _ = sbcutilities.GetSystemDetails(systemname)
var err error = sbcPage.Execute(w, Page{
Title: "SBC Details",
Content: sbcs,
})
if err != nil {
panic(err)
}
}
func sbcs(w http.ResponseWriter, r *http.Request) {
fmt.Println("Inside SBCS func()")
r.ParseForm()
name := r.FormValue("systemName")
var sbcs, _ = sbcutilities.GetSystemDetails(name)
fmt.Println(sbcs)
var err error = sbcPage.Execute(w, Page{
Title: "SBC Detail",
Content: sbcs,
})
if err != nil {
panic(err)
}
}
{{define "content"}}
<div class="w3-responsive">
<div class="w3-col">
<table class="table table-hover">
<thread>
<th>System Name</th>
</thread>
<tbody>
{{range . }}
<tr>
<td>{{.SystemName}}<form action="/sbcs" method="post" name="systemName" id="systemName" > <button type="button" type="submit" value="{{.SystemName}}" class="btn btn-primary">Show Details</button></form></td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</div>
{{end}}
systemnames is not called on button click, because it is bound to /systemnames while the form sends a request to /sbcs.
I recommend watching network activity in chrome dev tools. You will see where requests are sent to and what values are sent.