Request the selected dropdown value from HTML template?

I’m trying to show whatever value from my dropdown menu that was selected, onto my local server.

Here’s my HTML from the page with the dropdown:

		<select name="jdbcDriver" id="jdbcDriver" onchange="$('#submit').prop('disabled', $('#jdbcDriver option:selected').val() == 'default')">
				<option selected disabled value="default">Select Driver</option>
				<option value="1">SQL Server</option>
				<option value="2">Oracle</option>

And in my function I have:

func AddProgram(responseWriter http.ResponseWriter, r *http.Request) {

 	page := Model.Page{
 		TemplateFilename: []string{"NewProgramData.template.html"},
 		ObjectMap:        objectMapDefinition{
 		       JdbcDriver: r.FormValue("jdbcDriver"),


 	Ui.Render(responseWriter, page)

and then finally in my NewProgramData.template.html, I am doing this:

{{ .ObjectMap.driver}}

However nothing shows up. I would be grateful for any help, thanks.

As far as I understood your problem, there is no {{ .ObjectMap.driver }} it is called {{ .ObjectMap.JdbcDriver }}, or is it just a copy & paste typo?

1 Like

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