Numerierung der Teilnehmer durch Hilfsvariable i in main()
This commit is contained in:
parent
48f104650f
commit
cb6f83139f
7
main.go
7
main.go
@ -14,6 +14,7 @@ type Person struct {
|
||||
type Instructor Person
|
||||
|
||||
type Participant struct {
|
||||
id int64
|
||||
Person
|
||||
Company string
|
||||
}
|
||||
@ -29,13 +30,15 @@ type Briefing struct {
|
||||
|
||||
func main() {
|
||||
mux := http.NewServeMux()
|
||||
i := 1
|
||||
|
||||
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
template.Must(template.ParseFiles("templates/index.html")).Execute(w, nil)
|
||||
template.Must(template.ParseFiles("templates/index.html")).Execute(w, i)
|
||||
})
|
||||
mux.HandleFunc("/add-participant/", func(w http.ResponseWriter, r *http.Request) {
|
||||
template.Must(template.ParseFiles("templates/index.html", "templates/participant.html")).ExecuteTemplate(w, "participant", nil)
|
||||
i++
|
||||
template.Must(template.ParseFiles("templates/index.html", "templates/participant.html")).ExecuteTemplate(w, "participant", i)
|
||||
})
|
||||
|
||||
log.Fatalln(http.ListenAndServe(":8080", mux))
|
||||
|
@ -38,19 +38,21 @@
|
||||
+
|
||||
</button>
|
||||
|
||||
<div id="participant-{{ .ID }}">
|
||||
<label for="participant-first-input-{{ .ID }}">Vorname</label>
|
||||
<input type="text" name="participant-first" id="participant-first-input-{{ .ID }}" />
|
||||
<div id="participant-{{ . }}">
|
||||
<label for="participant-first-input-{{ . }}">Vorname</label>
|
||||
<input type="text" name="participant-first" id="participant-first-input-{{ . }}" />
|
||||
|
||||
<label for="participant-last-input-{{ .ID }}">Nachname</label>
|
||||
<input type="text" name="participant-last" id="participant-last-input-{{ .ID }}" />
|
||||
<label for="participant-last-input-{{ . }}">Nachname</label>
|
||||
<input type="text" name="participant-last" id="participant-last-input-{{ . }}" />
|
||||
|
||||
<label for="participant-company-input-{{ .ID }}">Firma</label>
|
||||
<input type="text" name="participant-company" id="participant-company-input-{{ .ID }}" />
|
||||
<label for="participant-company-input-{{ . }}">Firma</label>
|
||||
<input type="text" name="participant-company" id="participant-company-input-{{ . }}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit">Senden</button>
|
||||
<button type="submit" hx-post="/submit/" hx-target="#participants" hx-swap="beforeend" hx-trigger="click">
|
||||
Senden
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<script src="/static/js/htmx.min.js" type="text/javascript"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user