I’m trying to send some data with a GET Request from a HTML-Table. Simple like that:
templ ProjectMatchTable(matches []model.Match) {
<table class="striped">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Name</th>
<th scope="col">Match %</th>
<th scope="col">Verfügbarkeit %</th>
<th scope="col">Verfügbarkeit Engpass</th>
</tr>
</thead>
<tbody>
for _, match := range matches {
<tr>
<th scope="row">
<div>
<input name="employeeNumber" type="hidden" value={match.Name} />
<button hx-get="/showExternalProfile" hx-target="#externalProfile" hx-params="*" hx-include="[employeeNumber='employeeNumber']">Anzeigen</button>
</div>
</th>
<td>{ match.Name }</td>
<td>{ strconv.Itoa(match.Score) } %</td>
<td>{ strconv.Itoa(match.Availability) } %</td>
<td>{ match.AvailabilityConcerns }</td>
</tr>
}
</tbody>
</table>
}
But on the Server I don’t see any parameter, which should be send along with hx-get. I tried several ways, also hx-get="/showExternalProfile/employeeNumber={match.Name}
but HTMX is senden {match.Name} as String Value it that case.
On the Server (GO) I’m just using this test code at the moment:
func showExternalProfile(w http.ResponseWriter, r *http.Request) {
employeeNumber := r.URL.Query().Get("employeeNumber")
fmt.Println(employeeNumber)
templ.Handler(external_profile.ExternalProfile()).ServeHTTP(w, r)
}
The match.Name contains a value “Max Mustermann” for example. Which is correctly loaded into the HTML-Table. If I hardcode hx-get="/showExternalProfile?employeeNumber=123"
this also works.
I see a lot of examples in HTMX Documentation which are doing exactly the same. But it’s just not working. What do I miss?