From b570b77a17abd54783d76bba2f7a99a23c3319dd Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Thu, 5 Oct 2023 17:00:34 +0200 Subject: [PATCH] i und j sollten jetzt richtig verwendet werden --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index fe552d4..26a361d 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func main() { var b Briefing mux := http.NewServeMux() - i = 1 + i, j = 1, 1 mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/")))) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -42,6 +42,7 @@ func main() { }) mux.HandleFunc("/add-participant/", func(w http.ResponseWriter, r *http.Request) { i++ + j = i template.Must(template.ParseFiles("templates/index.html", "templates/participant.html")).ExecuteTemplate(w, "participant", i) }) mux.HandleFunc("/submit/", func(w http.ResponseWriter, r *http.Request) { @@ -51,7 +52,8 @@ func main() { b.Time = r.PostFormValue("time") b.State = r.PostFormValue("state") b.Location = r.PostFormValue("location") - for j = 1; j <= i; j++ { + + for ; j <= i; j++ { b.Participants = append(b.Participants, Participant{ ID: j, Person: Person{ @@ -61,7 +63,6 @@ func main() { Company: r.PostFormValue(("participant-company-" + fmt.Sprint(j))), }) } - fmt.Println(b) }) log.Fatalln(http.ListenAndServe(":8080", mux))