Keep in mind that the only html code that is sent to the browser is sent by your control, so if you’re getting this error, I susp ct that you’re not setting the Name attribute (because you’re calling getElementsByName).
In the case of txtcmp_code1, that is the name of the control in Xojo. And this is set upon design, and is not writable.
But my problem is much worse than I thought : after dragging an instance of a basic WebControlWrapper with nothing into it over the WebPage, a run in the IDE results in “Launching” without the icon, and the program gets stuck there.
I shall have to study more in detail the examples using the same class to understand. Hope my old brain will get it.
I have renounced for the moment creating a new WebControlWrapper class from scratch. Instead, I am experimenting by modifying the HTMLArea example from the WebSDK/Examples folder.
This fires the Execute event in the WebControlWrapper and in there I was able to retrieve the elements of the JavaScript array. Good beginning. It should enable me to get back JavaScript variables in Xojo much more elegantly than by changing the HashTag.
Function SetupJavascriptFramework() As String
ExecuteJavaScript("var fruits = [""Apple"", ""Orange"", ""Donkey""]")
ExecuteJavaScript("Xojo.triggerServerEvent('"+me.ControlID+"', 'ExecuteEvent', fruits)")
End Function
Edit : I have now successfully used the same kind of code from elsewhere. It is a great way to send back JavaScript variables to Xojo !