I am writing a traditional web app using OutSystems 11, and am working on a Windows 10 machine...

Hello,

I am trying to create a button that copies text from either a variable or an input textbox to the clipboard. I've done some reading, and it looks like I will need to write some javascript. It seems that the most popular way to do this involves using document.execCommand('copy'). Can someone help me figure out how to do this. I have limited javascript knowledge, and was having a hard time following other posts on the topic.

Thanks,

Ryan


Hello Ryan.

You can create a simple JavaScript script.

  • Name the input.
  • Create an action with a JavaScript widget.
  • Give the Input Name to JavaScript
  • Done,


I attached a working example.

I get the following error. I believe it is because the app I am maintaining is based on the SilkUI framework, so I don't have the 'Run Client Action' or 'JavaScript' execution box features. In my environment, It think I need to run the javascript using the extended properties of a button. Can you show me how I could do that (or suggest another way)? Thanks.


Nuno Reis wrote:

Hello Ryan.

You can create a simple JavaScript script.

  • Name the input.
  • Create an action with a JavaScript widget.
  • Give the Input Name to JavaScript
  • Done,


I attached a working example.



Solution

I did this in Reactive, you are probably in Traditional.

It is even easier. You just need to write the Jscode on the button.

Solution

Thank you! Your demo was very clear, and was exactly what I needed.

Nuno Reis wrote:

I did this in Reactive, you are probably in Traditional.

It is even easier. You just need to write the Jscode on the button.