I. Description
When designing reports, we usually encounter requirement, that is to directly copy the content of a text area by clicking a button, as shown below:
II. Steps
2.1 Create a new template
1) Click cell A1, select Cell Element, choose Insert Text, and enter the HTML code as follows:
<textarea rows="20" cols="20" id="biao1">User Copy are</textarea>
<input type="button" onclick="copytext()" value="copy">
2) Click Cell Attributes > Other, and select Display by HTML, as shown in the figure below:
2.2 Import JS file
1) Create a new JS file
Add a file copy.js under the path %FR_HOME%\webroot\scripts\js. You can click to download the copy.js file:
The code in the JS file is shown as below:
function copytext(){
var copytext2=document.getElementById("biao1");//Get the text box
copytext2.select();//Select the content of the text box
document.execCommand("copy");//Execute browser's copy command
alert("Copy Success!");//The output has been copied text
}
2) Quote JavaScript
Click Template > Web Attributes > Reference JavaScript. Select the JS file created in the previous step, and click Add to let the template reference this file, as shown in the following figure:
III. View the Effect
3.1 PC side
3.2 Mobile
Mobile devices are not supported.