First sorry for my bad english, I'll try to do my best.
Im trying to create a webapp that shows the name of servers, their IPs, ping, ports, etc...
Here is a part of my code:
MAIN.GO :
type Widget struct {
Ipport string
Number string
State string
Colport string
Blink string
}
type resulthtml struct {
Name string
Affordi string
Afflieu string
Affip string
Affresping string
Affresport string
Affport string
Affactif string
Colping string
Lisports []Widget
Blink string
}
var prout []resulthtml
// 80% of the missing code is here like ping function, etc, etc
func main() {
//.........some code here.............
http.Handle("/favicon.ico", http.NotFoundHandler())
http.HandleFunc("/", affichagePing)
http.ListenAndServe(":2692", nil)
}
func affichagePing(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.ParseFiles("test.html"))
tmpl.Execute(w, prout)
}
And TEST.HTML :
<div id="cadre_affich1">
<table id="Affichageglobal">
<thead>
<tr>
<th class="AffichageLigneT" style="width: 3%;"></th>
<th class="AffichageLigneT" style="width: 15%;">Name</th>
<th class="AffichageLigneT" style="width: 8%;">Type</th>
<th class="AffichageLigneT" style="width: 6%;">Place</th>
<th class="AffichageLigneT" style="width: 14%;">IP</th>
<th class="AffichageLigneT" style="width: 10%;">Ping</th>
<th class="AffichageLigneT" style="width: 41%;">Ports</th>
<th class="AffichageLigneT" style="width: 3%;"></th>
</tr>
</thead>
<tbody>
{{range .}}
<tr>
<td class="AffichageLigneRefr"></td>
<td class="AffichageLigneNom"><span class="AffichageStatut" style="background-color:{{.Colping}}"></span><span>{{.Name}}</span></td>
<td class="AffichageLigneType">{{.Affordi}}</td>
<td class="AffichageLigneLieu">{{.Afflieu}}</td>
<td class="AffichageLigneIP">{{.Affip}}</td>
<td class="AffichageLigneResPing"><span class={{.Blink}} style="color:{{.Colping}}">{{.Affresping}}</span></td>
<td class="AffichageLignePorts">{{range $v := .Lisports}}<span class={{$v.Blink}}>{{$v.Number}}</span>{{end}}</td>
<td class="AffichageLigneEdit"></td>
</tr>
{{end}}
</tbody>
</table>
</div>
I have no problem displaying what I want. Now I want to refresh a specific row without reloading the whole page (its ping, name, etc...) when I click on the first cell of it. I know I have to do it through Javascript that will send informations to a Go Handler but well, I spent hours and tried so many things...
I can't get it to work.
Thank you very much.