Run Javascript from custom HTML

Hi guys,

I am creating custom html during run time.
I want to add a javascript into the html which should change the text on a web label.

what I am doing so far is

rectangle1 - is a rectangle control
p - is a string that holds custom html
label1 - is a web label (which we want to change)

in button action event I have written

[code]self.ExecuteJavaScript “document.getElementById(”"" + Rectangle1.ControlID + “”").style.overflow = ‘auto’;"

Dim p As String
p = “document.getElementById(”"" + Rectangle1.ControlID +""").innerHTML = ’ "
For i As Integer = 0 to 100
p = p + " <div onclick = {document.getElementById(""" + label1.ControlID + “”").innerHTML = this.id;} id = “”"+ str(i) +""" style="“background-color:red; height:22px; line-height:22px;border-top:1px solid white; “”> row “+str(i)+””
Next i
p = p + “’;”

TextArea1.Text = p
Self.ExecuteJavaScript p
[/code]

The above code fills the rectange1 with new html - – - BUT when you click on the row it does not change label to the id of that div.

any ideas??? anybody

I wouldn’t rely on this. We reserve the right to change the layout of the DOM at any time as the framework progresses, so code like this is likely to break in the future.

Have you tried out the WebSDK?

is it impossible to get it to work, like it is now?

No, not impossible, just unsupported.

by WebSDK, do you mean creating a custom control ?
instead of using pure HTML?

Yes. Inserting HTML into the contents of an existing control is not supported, but if you were to create your own control and insert HTML into that, your code is less likely to be broken by framework changes.

As far as the WebLabel goes, I still suggest that you not make changes directly to the DOM. If you’re using the WebSDK, you could send the change you want up to your control and them modify the label using Xojo code in an event on the server.

ok, thanks for that.