Javascript clear textarea

  1. 7 weeks ago

    Hi... I'm pretty new to JS, so this might be a basic question
    Can anyone tell me why is this code failing on a button action ?

    Dim Id as String = TextArea1.ControlID
    me.ExecuteJavaScript("document.getElementById('"+id+"').value = '';")

    thanks
    R

    This is probably what you're looking for (untested):

    me.ExecuteJavaScript("document.getElementById('" + Me.ControlID + "_inner').value = '';")
  2. Christian S

    Jul 31 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    What do you want to do?

    Your button could better just set the textfield in Xojo to "" and than let Xojo send javaScript to browser.

  3. Tim P

    Jul 31 Pre-Release Testers Rochester, NY

    ControlID is almost always the ID of some outter div wrapper. Check the DOM to see if the TextArea control has a div wrapper, and what the inner textarea id might be.

  4. Anthony C

    Jul 31 Pre-Release Testers, Xojo Pro, Third Party Store Answer GraffitiSuite Developer

    This is probably what you're looking for (untested):

    me.ExecuteJavaScript("document.getElementById('" + Me.ControlID + "_inner').value = '';")
  5. It's my first dive into Js... so...

    @ChristianSchmitz I am just experimenting and trying to learn. It's not something I'm going to use in a real project
    @Tim P Got it. Hit F12 in chrome and saw the real ID of the textarea... Now I see what you mean. The suffix "_inner" is always added to the object inside the outter wrapper? Can I take this as a rule?

    Thanks Anthony!

    R

  6. Anthony C

    Jul 31 Pre-Release Testers, Xojo Pro, Third Party Store GraffitiSuite Developer
    Edited 7 weeks ago

    @Roman V Can I take this as a rule?

    Pretty much, but always verify by inspecting in the browser.

  7. 6 weeks ago

    Michel B

    Aug 1 Pre-Release Testers, Xojo Pro RubberViews.com

    @Roman V It's my first dive into Js... so...

    @ChristianSchmitz I am just experimenting and trying to learn. It's not something I'm going to use in a real project
    @Tim P Got it. Hit F12 in chrome and saw the real ID of the textarea... Now I see what you mean. The suffix "_inner" is always added to the object inside the outter wrapper? Can I take this as a rule?

    Thanks Anthony!

    R

    Greg O'Lone has regularly warned that the "_Inner" suffix may not always be used, and that it may change.

  8. Anthony C

    Aug 1 Pre-Release Testers, Xojo Pro, Third Party Store GraffitiSuite Developer

    @Michel B Greg O'Lone has regularly warned that the "_Inner" suffix may not always be used, and that it may change.

    @Anthony C Pretty much, but always verify by inspecting in the browser.

or Sign Up to reply!