Copy to clipboard
Hi all,
I want to copy the text of a text field to the clipboard.
Apparently, the usual JavaScript way does not work.
In a button I have implemented the following code. Any idea what's wrong about it?
var copytext = fd.field('Status').control().value()
copytext.select();
document.execCommand("copy");
I have also tried to use the command fd.execCommand("copy") instead of document.execCommand("copy"), but it didn't work.
Thank you very much in advance for help!
I want to copy the text of a text field to the clipboard.
Apparently, the usual JavaScript way does not work.
In a button I have implemented the following code. Any idea what's wrong about it?
var copytext = fd.field('Status').control().value()
copytext.select();
document.execCommand("copy");
I have also tried to use the command fd.execCommand("copy") instead of document.execCommand("copy"), but it didn't work.
Thank you very much in advance for help!
Hi!
You should change a code a little bit:
1) For a single-line text field:
2) For a multi-line text field:
You should change a code a little bit:
1) For a single-line text field:
Code: Select all
fd.field('Status').control()._el().find('input').select();
document.execCommand("copy");
Code: Select all
fd.field('Status').control()._el().find('textarea').select();
document.execCommand("copy");
Hi,
thanks for your help. It works, but only when the form is used in edit mode.
I guess this is because the field cannot be selected in display mode.
Is there a way to copy the text of a variable to the clipboard?
If we take the above-mentioned example. Why can't I select "copytext"? Or how can I do that?
Thank you very much in advance!
thanks for your help. It works, but only when the form is used in edit mode.
I guess this is because the field cannot be selected in display mode.
Is there a way to copy the text of a variable to the clipboard?
If we take the above-mentioned example. Why can't I select "copytext"? Or how can I do that?
Thank you very much in advance!
Hi!
'Copytext' will be just a value in the example above, not a DOM element, so select() method will be useless for it.
Please try to use this code for the Display Form to select an element (you can test it in the browser console):
'Copytext' will be just a value in the example above, not a DOM element, so select() method will be useless for it.
Please try to use this code for the Display Form to select an element (you can test it in the browser console):
Code: Select all
rng = document.createRange();
rng.selectNode(fd.field('FieldInternalName').control()._el()[0]);
sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(rng);
-
- Information
-
Who is online
Users browsing this forum: No registered users and 19 guests