Web Search Field, How to clear text with code

Xojo version 2022r4.1 on Windows 10
Simple question. How do I clear the text from the WebSearchField using code?
I know that I can click on the X in the search field but I need to clear it using code in a button event.
I tried mysearchfield.text = “” but that did not do anything.
Thanks

did you call updatebrowser after setting the text property ?

Maybe this is related?
Setting WebSearchField.Text to a string value in code does not do anything

1 Like

Updatebrowser did not work. Thanks for the suggestion.

Thanks for the link. That is the same problem that I am having. Maybe Xojo will fix it one day.

1 Like

2023r2 includes a fix for that, see Issue #72099 :slight_smile:

Thanks @AlbertoD for the case number!, I’ve closed it as a duplicate.

1 Like

That is great! I will get the latest version.
Thanks

Well darn, 2023r2 has not released yet.

If you want to test pre-release versions, check:

is an old post, maybe something have changed since. You can always send an email to hello@xojo.com and ask if you can become a tester.

Gary has a Pro Licence he gets the beta channel as well.

Sorry Gary, yes, I meant it will include the fix, but it’s in beta.

I wonder why it doesn’t work?

Var js As String
js = "document.getElementById('" + SearchField1.ControlID + "_search').value = ''; console.log('" + SearchField1.ControlID + "');" 
ExecuteJavaScript(js)

“console.log” works.

if execute this code in console everything works fine, Search Field 1 is cleared

That seems to be working fine on Safari and Chrome, what Browser and OS are you using?

Windows 10. I tested on Chrome, Firefox and Edge - does not work :frowning:

My test program

In Button1.Pressed, try to remove the first line:

// Remove this line
SearchField1.Text = ""

Leave just the JS part.

1 Like

works :partying_face:

2 Likes