Mark an option as selected - golang

Good afternoon

I can not mark option as selected,


{{range $k, $group := .groups}}
<option value=".Id" {{if eq .Id .categorys.Group}}selected{{end}}>.Name

When I pass the “if” nothing else appears after
Can anybody help me?

What is the error that the server returns?

Notice that unless you need $k and $group you can just do:

{{range .Groups}}

Try in your Go code:

s := struct{}{} // replace struct{}{} with the the struct you pass in your template
fmt.Println(s.ID == s.categories.Group)

If the above doesn’t print true then check the individual values.


Problem solved using ajax on return to template

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.