Focus and highlight text input

Hello,

Is it possible to focus and simultaneously highlight the contents of a text input using code?

$w (“#textInput”). focus ();

So that typing will then overwrite whatever was there previously, or the user chan choose to keep it.

Many thanks,

Luke

How to highlight text inside a TEXT-BOX…

And here the example…

https://russian-dima.wixsite.com/meinewebsite/highlight-mark-some-text

So that typing will then overwrite whatever was there previously, or the user chan choose to keep it.

To overwrite something inside the TEXT, you first will have to get the whole text out of the TEXT-BOX, then replace some parts of the text and put it back into the TEXT-BOX.

Thanks for this. I think it’s a slightly different problem though. I want the text inside a text input to be highlighted/selected on focus. Is that possible.

Like this: https://stackoverflow.com/questions/4067469/selecting-all-text-in-html-text-input-when-clicked

I’m imagining something like:
$w (“#textInput”). selectAll ();

Use the HTML-Component for your purposes…

Implement this example to your generated HTML-Component-CODE…

var input = document.getElementById("textBoxId");
input.value = "Cup of tea";
input.setSelectionRange(0, 3); // Highlights "Cup"
input.focus();

I don’t think you will be able to use the INPUT-ELEMENT to create your wished functionality (but not sure).

Maybe you can find more info here …