### Example HelloWorld B4J Event via JS Function

WebApp Example HelloWorld which raises a B4J Event via JS Function.
In the event a parameter is passed which is shown in the B4J Log.
See example WebApp B4J Event as a base with following changes:
HTML
Replace
<button id="btnabout" title="About">About</button>
By
<button onClick="RunFunction();">About</button>
Add in the script section the function with label helloworld as a parameter.
function RunFunction() {
b4j_raiseEvent("about_event", {"myheading": $("#lblhelloworld").text()});
}
B4J - helloworld.bas
Handle click on the button with id btnAbout - Note in the index.html all id's are in lowercase
For tests all entries of the parameter map are listed.
`Sub about_event(params As Map)
Log("about_event :: Start = " & params.Size)
For i = 0 To params.Size - 1
Log(params.GetKeyAt(i) & " = " & params.GetValueAt(i))
Next
'In index.html a div with id btnabout is defined. This is used to display the about info.
lblmessage.SetHtml("

## Hello World (again) @ " & DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) & "

")
'Another option is to show the javascript standard Alert Dialog
'ws.Alert("B4J HowTo Hello World" & CRLF & "by Robert W.B. Linn, Pinneberg, Germany")
Log("about_event :: End")
End Sub`

Changed: 2018-06-07 09:27, Category: WebApps, File: T6C277M2066.htm, ID: 2066