我正在使用此复制到剪贴板脚本来复制返回到表行的值。当我使用实际字段时它工作正常,但当我尝试从输入的行中复制值时却不行。既然我正在使用 getElementByID.. 显然不是专家,但理论上它似乎应该工作
<script type="text/javascript"><!--
// input field descriptions
var desc = new Array();
desc['PROC_CODE'] = 'Procedure Code';
desc['STATUS'] = 'Status';
function CopyFields(){
var copytext = '';
for(var i = 0; i < arguments.length; i++){
copytext += desc[arguments[i]] + ': ' + document.getElementById(arguments[i]).value + '\n';
}
var tempstore = document.getElementById(arguments[0]).value;
document.getElementById(arguments[0]).value = copytext;
document.getElementById(arguments[0]).focus();
document.getElementById(arguments[0]).select();
document.execCommand('Copy');
document.getElementById(arguments[0]).value = tempstore;
}
--></script>
</head>
<body>
<table width="100%" border="0" cellpadding="5" cellspacing="1">
<tr bgcolor="#F0F0F0">
<td colspan="5" align="center" class="th2">1) Procedure Code Record</td>
</tr>
<tr bgcolor="#F0F0F0">
<td width="12%" align="right" bgcolor="#CCCCCC" class="tdFieldHeadingsR1">
Procedure Code </td>
<td width="1%" align="right" bgcolor="#FFFFFF" class="tdFieldHeadingsR1"> </td>
<td width="55%" bgcolor="#FFFFFF" class="tLBL1l" id="PROC_CODE" name="PROC_CODE">
</td>
</tr>
<tr bgcolor="#F0F0F0">
<td width="12%" align="right" bgcolor="#CCCCCC" class="tdFieldHeadingsR1">
STATUS </td>
<td width="1%" align="right" bgcolor="#FFFFFF" class="tdFieldHeadingsR1"> </td>
<td width="55%" bgcolor="#FFFFFF" class="tLBL1l" id="STATUS" name="STATUS" >
</td>
</tr>
<a href="#" onclick="CopyFields('PROC_CODE', 'STATUS');">Copy values of text fields to clipboard</a>