How to "inject" text into a multiline text input using a button

Alright,

The concept seems pretty easy, just from browsing I did find one option from someone using a jQuery script to accomplish this… but it hasn’t worked for me.

Essentially I have developed shortcodes for messages that are replaced with information from the database, but I wanted to have a dropdown menu with the title of those values and when they select that value then the shortcode is automatically inputted into the text box.

For example… the user is trying to text a customer and I have it set so if they were to use {FNAME} inside their message it would automatically replace that value with the customers first name.

Because the user does not know all the shortcodes such as {FNAME}, I want a list of shortcodes in a drop-down menu but I don’t want them to look like {FNAME}, they will be displayed as “Customers First Name” and when they click that button, it inserts the shortcode automatically.

I haven’t found a native way to accomplish this and this is the first time I am completely hung up on this platform.

Heres a link to the jQuery solution, perhaps someone can help me with what I am doing wrong?

I’d like it to do exactly as it shows but I want it to append to the already existing text not go where the caret is because to open the dropdown the user must click off of the text box and it wouldn’t exist.

Are you asking how to insert a different value than shows in the dropdown or how to insert that value into a text input?

When a button is clicked, set a state on a multiline input. Within the multiline input set a conditional statement to change the initial content.

I found a solution similar to this.

I created a custom state called text

Then when the button is clicked, in the workflow I set the value of ‘text’ to Multiline Input’s Value:append"TEXT I WANT TO INSERT", then I set the custom state 'text’s value as the multiline input’s initial value and reset the group that it’s located in and set the focus back to the same multiline input.

Works pretty smooth, thanks for the response.

1 Like

That’s exactly what I meant. Good that you found the solution :wink:

This topic was automatically closed after 70 days. New replies are no longer allowed.