A variable not get in the same execution cycle the value of a field located in a WebControlWrapper

When I try to capture on a variable the text of a field located in WebControlWrapper control, gets the value in an execution later. Is there any way to fix it? I use Xojo Pro 2016r3. Thank you.

Example code:

Dim Email as String, MyJS as String
MyJS = "document.getElementById('" + webpage1.TextJS.ControlID + "_inner').value =document.getElementById('email').value;"   
webpage1.TextJS.ExecuteJavaScript(MyJS)
Email=str(webpage1.TextJS.Text)
msgbox "Email:"+Email

Where TextJS is a WebTextField on a Webpage. And “email” control is a control located in the HTML of WebControlWrapper object (MyWebsiteHTMLCode constant):

<Input class = "form-control" id = "email" name = "email" type = "text" />

Unfortunately this won’t work. Code that you write is not sent line by line to the browser and executed. Instead, all of the commands that you have in that method are coalesced and sent at the same time.

A better bet would be to have your javascript code trigger an event on the server and process the contents there. The WebSDK docs and example files have examples of how to do this.

Could indicate a concrete example of WebSDK where to apply what I need? It is not easy to consult documentation WebSDK for me and i see a small number of examples. Thank you.

I can not retrieve the value of a text field if I put it in the webpage open event, and then recovered from a webbutton action:

In Webpage Open event (H and W are WebTextFields):

JS=“document.getElementById(’” + H.ControlID + “_inner’).value=screen.height;”
H.ExecuteJavaScript(JS)
JS=“document.getElementById(’” + W.ControlID + “_inner’).value=screen.width;”
W.ExecuteJavaScript(JS)

In action button:
Dim widthwin as integer, heigthwin as integer
widthwin = val(W.Text)
heigthwin=val(H.Text)

However, I do see onscreen the values in the webtextfields before pressing the webbutton. Please, help.

Why not just use a text field in Xojo? You’re re-inventing the wheel here.

Edit: Oh, nevermind I see you’re trying to get the screen details.
You need to implement the ExecuteEvent event handler to get data back from your control in the browser (as Greg alluded to)

I’m using WebTextFields, but I’m trying to fill a value of Javascript.

I am trying to recover any value from javascript to Xojo and do not know how. I am not able to create new handler events when there are not predefined. Capturing a javascript value should be easier :frowning:

Tim, I just sent you an email. Delighted to speak with you :slight_smile:

Thanks.

[quote=290734:@Manuel Salguero]I am trying to recover any value from javascript to Xojo and do not know how. I am not able to create new handler events when there are not predefined. Capturing a javascript value should be easier :frowning:
[/quote]
The ExecuteEvent(Name as String, Parameters() as Variant) event can pass data back to Xojo from JavaScript by triggering a server event with Xojo.triggerServerEvent(controlID As String, eventName As String, userData As Array), as covered on page 20 of the WebSDK documentation.

The problem is that I am looking ExecuteEvent on Xojo native web controls, when only he was in the WebControlWrapper controls. I do not understand why it has not moved this functionality also to other all web controls …

I find not a document With the name “Xojo Web SDK documentation”. However, I found something in some examples. Thank you.

Look in the Extras folder, in the Xojo folder. That is where you find a folder called WebSDK, and inside, there is WebSDK.pdf.

Oh, Oh, I’m sorry. Thank you very much!! :slight_smile: