Gopherjs/WASM: How to parse FormData into Map object?

Hi there, Hope you are having a great day/night.

Sorry in advance for the links but as a new user I can can only use 2 mdlinks.

I’m trying to parse a form on submit in order to get its keys/values. I’am using FormData interface to do it with the package HTML - from GoWebApi

However, I am not able to loop through it, as I am confused about how to make callback from ForEach

func (*FormData) ForEach

func (*FormData) ForEach ¶

func (_this *FormData) ForEach(callback *FormDataForEach, optionalThisForCallbackArgument interface{})

Here my Code:

func (p *Page) onInc(e *vecty.Event) {

formEl := html.HTMLFormElementFromJS(DocumentGetElementById"form333").JSValue())


formData := html.NewFormData(formEl)

dataLoop := formData.ForEach()

---< callback here >----

for k, v := range dataLoop {





Here the form elements:

<form id="form333" style="margin: 0px;"><label for="Fname">First name:</label><br><input type="text" id="Fname" name="Fname"><br><label for="Lname">Last name:</label><br><input id="Lname" type="text" name="Lname"><input type="submit" value="Text input" class="button is-danger"></form>

According the doc I need to make a FormDataForEach Callback & optionalThisForCallbackArgument interface{} but I have no clue how to that after I tried to that the last 24 hours and as im new in GO.

I also tried other functions such as:

  • FormDataForEachFromJS -

  • FormDataEntryIteratorValueFromJS

  • ArrayFromJS

I have not been able to make it working so far, and i’am totally confused.

so, if somebody can show me how to handle the callback or any other ways to get the formdata key,value would be greatly appreciated.

Thanks in advance.


  • I am not using syscall/js which is not working even though I set "go.toolsEnvVars": { "GOARCH":"wasm", "GOOS":"js", }, "go.testEnvVars": {"GOARCH":"wasm", "GOOS":"js", } in vscode settings.json

  • I am not using other useful libraries like because I only use the dom and not http.request.