GetElementId

Hi,

This is a VB.net code: Does anyone know how to accomplish this in xojo?

Htmlviewer1.document.GetElementById(“Email”).InnerText = “hello”

Basically it enters “hello” on a text both with element id: email.

You’d have to use a javascript inject, which funny enough would look very similar.

I’m having bad time with it, I googled a lot and tried this:

HTMLViewer1.ExecuteJavaScript("document.getElementById(‘email’).InnerText = “hello”

doesn’t want to work either.

Nevermind, I got it :slight_smile: Here’s the code just incase anyone else wants it.

http://documentation.xojo.com/index.php/HTMLViewer.ExecuteJavaScript

Not sure what’s so overcomplicated about this, but to change the text from “xojo” to “whatever is written in textfield1”, cant I just do this?

jsSrc = “document.forms[0].elements[‘search’].value=”“xojo”“;” to
jsSrc = “document.forms[0].elements[‘search’].value=“textfield1.text”;”
Apparantely that’s giving me an error.

I’ve also tried:
dim text as string = textfield1.text

jsSrc = “document.forms[0].elements[‘search’].value=“text”;”

I’ve played around with quotes too, what am i doing wrong?

This should work - untested though

jsSrc = “document.forms[0].elements[‘search’].value=”"" + textfield1.text + “”";"

Worked perfectly. Never thought about adding “+”. Thanks