Click to See Complete Forum and Search --> : Copy and paste function


puredemo
04-19-2006, 04:12 PM
Hey all,

Is there a way to get the username checkbox in the code below to process the values from the top fields when create / copy is hit?

My setvalues function is definitly not working right. I was told to have to reference the set(t) function but I am bad bad bad at syntax. Any help would be greatly appreciated.





<HTML>
<HEAD>
<style>
BODY {
MARGIN-TOP: 20px; FONT-SIZE: 11px; MARGIN-LEFT: 15px; COLOR: #333333; LINE-HEIGHT: 1.5; MARGIN-RIGHT: 15px; BACKGROUND-REPEAT: repeat-x; FONT-FAMILY: verdana, arial, helvetica, sans-serif; BACKGROUND-COLOR: #ffffff
}
</style>
<title>Copy to clipboard example</title>
<script type="text/javascript">

function enable() {
var clip = form.fn.value + " called in: ID \""+ form.sn.value + "\" needs unlocked for " + form.tl.value + ". I enabled " + form.fn.value + "'s " + form.tl.value + " ID and verified login.";
window.clipboardData.setData('Text',clip);
}

function reset() {
var clip = form.fn.value + " called in: ID \""+ form.sn.value + "\" needs a password reset for " + form.tl.value + " login. I verified ID validation criteria, reset " + form.fn.value + "'s " + form.tl.value + " password and confirmed login.";
window.clipboardData.setData('Text',clip);
}

function setT(n){
document.getElementById("cons").value=n
}


function cnotes(){
var objects = document.getElementsByTagName("input");
var t="";

for(var i=0;i<objects.length;i++)
{
if(objects[i].checked) t+=(objects[i].value+"\n\n");
}


setT(t);
document.getElementById("cons").createTextRange().execCommand("copy");
}


function setvalues("t")
{
if (C1.checked)
{
"test1" + form.fn.value;
}
elseif (C2.checked)
{
"test2";
}
elseif (C3.checked)
{
"test3";
}
else (C4.checked)
{
"test4";
}
}


</script>
</head><body>




<form name="form">
Admin clipboard<p>
Name:<br>
<input type="text" name="fn" size="16"><br>
ID:<br>
<input type="text" name="sn" size="16"><br>
Tool:<br>
<input type="text" name="tl" size="16">
</form>
<a href="#" title="Copy it" onClick="enable()" onmouseover="window.status='Copy ID unlock text'; return true;">
ID Unlock</a>&nbsp;|
<a href="#" title="Copy it" onClick="reset()" onmouseover="window.status='Copy password reset text'; return true;">
PW Reset</a>&nbsp;|
<a onclick="form.reset(); clipboardData.clearData(); return false;" href="#" onmouseover="window.status='Clear all forms and clipboard'; return true;">
Clear All
</a>
</form>

<p>


<FORM name="checks">
<TABLE>
<TBODY>
<TR>
<TD><INPUT type=checkbox CHECKED name=C1 onclick="setvalues(this);"> Test </TD></TR>
<TR>
<TD><INPUT type=checkbox name=C2 onclick="setvalues(this);"> Why </TD>
<TD><INPUT type=checkbox name=C3 onclick="setvalues(this);"> Wontyou </TD>
<TD><INPUT type=checkbox name=C4 onclick="setvalues(this);"> work </TD></TR>
</TBODY></TABLE>
<P><TEXTAREA class=submit name=cons id=cons rows=20 cols=60></TEXTAREA></P><INPUT class=submit onclick=cnotes() type=button value="Create / Copy">&nbsp;&nbsp;&nbsp;<INPUT class=submit type=reset value=Reset name=B2>

<P><INPUT class=submit onclick="parent.location='mailto:linehad'" type=button value=Feedback>
</FORM></P>




</body>
</html>