changing a forms action attribute dynamically in a go template
Currently the forms action attribute is hardcoded to the id=2
How would I dynamically set it to the ID chosen by the user when pressing submit.
<p>Select a group</p>
<form method="POST" action="/artists/id?id=2">
<label for="selection">Artists:</label>
<select id="selection" name="selection">
<option value=1>Queen</option>
<option value=2>Pink Floyd</option>
<option value=3>Scorpions</option>
</select>
<input type = "submit" value ="submit" />
</form>
Go template:
<p>Select a group</p>
<form method="POST" action="/artists/id?id=2">
<label for="selection">Artists:</label>
<select id="selection" name="selection">
{{range .}}
<option value={{.Id}}>{{.Name}}</option>
{{end}}
</select>
<input type = "submit" value ="submit" />
</form>
Solution 1:
Used form method="GET" and made the changes suggested by @cerise