B4J Question WebApp - Get form-data with a websocket

moster67

Expert
Licensed User
I have a simple form in a web-page and when I click the submit button, I can see the values in webdev-tools in Chrome (network-tag).
I gave the form an ID and it triggers correctly in B4J but the map (Params) does not contain the values. It only contains values such as which=1, metaKey=false, pageY=268 etc).
How can I get values from the fields in my form in B4J so I can use them for further processing such as validation, entering data in a DB?
I am using WebSockets.
 

Erel

Administrator
Staff member
Licensed User

moster67

Expert
Licensed User
Thanks, and it works fine.
We are really fortunate thanks to all the stuff Erel has built for us.

Erel's example is using a form to get a file. If you wish to get the values of a text field, checkbox, radio, dropdowns (select) etc from a form, then just use the method GetValue like below:

B4X:
Public Sub GetFieldData(parts As Map)
    Dim myfielddata As Part = parts.Get("notes")
    Log(myfielddata.GetValue("UTF-8"))
    'do something with the data
    ws.Flush 'this is a server event so we need to explicitly call Flush
End Sub
 
Top