prefilled text in a textarea

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
mperez
New User
Posts: 9
Joined: Tue Sep 10, 2019 10:24 am
First Name: Michael
Last Name: Perez
Company Name: Manhattan Life Insurance
Contact:

prefilled text in a textarea

Post by mperez »

The record format contains a textarea and a button in a css panel. Prior to exfmt, the textarea field is pre-filled with some text by the RPG program. When it displays on the screen, the textarea has focus and its text is selected. I'm not sure how to unselect the text so the cursor is positioned after the pre-filled text. The intent is for the user to enter additional comments after the pre-filled text.

I tried adding the following js in the textarea onfocus() event, but the text remained selected.

input = this;
if (input.setSelectionRange) {
window.getSelection().removeAllRanges();
}
mperez
New User
Posts: 9
Joined: Tue Sep 10, 2019 10:24 am
First Name: Michael
Last Name: Perez
Company Name: Manhattan Life Insurance
Contact:

Re: prefilled text in a textarea

Post by mperez »

One workaround I found is to set the "no focus" property on the format. The user will need to click on the textarea, but the cursor will be positioned at the end of the prefilled text.
CAPL_INFO
Profound User
Posts: 38
Joined: Wed Jul 19, 2017 4:54 am
First Name: Nadine
Last Name: Gauthier
Company Name: CAPL
Country: France
Contact:

Re: prefilled text in a textarea

Post by CAPL_INFO »

You can get the HTML DOM element corresponding to the textArea and then set the selectionStart.
The DOM element should have the same ID as the PUI widget.
So basically

Code: Select all

var txtarea = document.getElementById("the_text_area_id_here");
txtarea.selectionStart = txtarea.selectionEnd;
Post Reply

Who is online

Users browsing this forum: BrianRees and 3 guests