wonder if you would be able to give me a bit of a helping hand with a bit of code.
Ive managed to find a bit of code that allows me to copy text from a div, but what i need is for the value of a form field to be included within the div and to be copyable.
Ive included the code, it only works in IE at the mo. I was hoping one of you clever people could you give me a few pointers on what needs to be done.
Thanks
Ive managed to find a bit of code that allows me to copy text from a div, but what i need is for the value of a form field to be included within the div and to be copyable.
Ive included the code, it only works in IE at the mo. I was hoping one of you clever people could you give me a few pointers on what needs to be done.
Thanks
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<script language="JavaScript">
function CalcSec () {
var secWidth = document.secondpricer.width.value / 1000
var secHeight = document.secondpricer.height.value / 1000
secSQM = secWidth * secHeight
document.secondpricer.sqm.value = secSQM
}
function copyCode() {
var div = document.getElementById('copybox');
div.contentEditable = 'true';
var controlRange;
if (document.body.createControlRange) {
controlRange = document.body.createControlRange();
controlRange.addElement(div);
controlRange.execCommand('Copy');
}
div.contentEditable = 'false';
}
</script>
<form name="secondpricer">
<table width="94%" border="0" cellpadding="1" cellspacing="1">
<tr>
<td width="18%">Width -
<input type="text" name="wdith" id="width" size="8">
mm<br> <br>
Height -
<input type="text" name="height" id="height" size="8" onKeyUp="javascript:CalcSec();">
mm</td>
<td width="17%">SqM
<input type="text" name="sqm" id="sqm" size="8" > </td>
<td width="65%"><div id="copybox">Copy text from this box / Text Template
here <br>
<br>
Square Meter Value is <strong>(Value From The SQM Form Field Here) </strong>²</div>
<br>
<br> <input type="button" name="copybutton" value="Copy" onClick="javascript:copyCode();">
</td>
</tr>
</table>
</form>
</body>
</html>