132
Views
7
Comments
Solved
Copy to clipboard button
Question

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


mvp_badge
MVP
Rank: #71
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.

Copy1.oml

Rank: #19654

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.



mvp_badge
MVP
Rank: #71

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.

Copy.oml

Rank: #19654

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.



Rank: #27427

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.

 

Hey Nuno, thanks for your great example. 

In your example you are using the input of textboxes, how is it possible to use variables as In1.

I tried it and get the error message: Cannot read property 'select' of null.

Thanks,

Alex

mvp_badge
MVP
Rank: #71
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.

Copy1.oml

Rank: #19654

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.