As my title suggests I am trying to figure out how to copy the contents of an entire form to clipboard. I have been able to locate code that allows me to copy single textareas/fields, but I need to be able to copy Labels, textarea/fields as a whole and keep their basic format (not font settings, or any of that, but things like table locations and such).
I am trying to create a “template” which will then be exported to a ticketing program. I want to see if I can at least get the sopy to clipboard to work for the whole thing first, then if I can at least get that I want to have it automatically post it to another programs like Service Center.
Any help would be greatly appreciated on this, I am about at my witts end since I have been trying to tweak code to get this to work for almost 2 weeks! ๐ฎ
function updateDescription () {
frm = document.form1;
var description = ""
<i> </i>description += "Action Steps: " + frm.ActionSteps.value;
<i> </i>description += "nUsers Affected: " + frm.UsersAffected.value;
<i> </i>description += "nCurrent Phone number: " + frm.CurrentPhone.value;
<i> </i>description += "nAlt Contact: " + frm.AltPhone.value;
<i> </i>description += "nProcedure: " + frm.Procedure.value;
<i> </i>description += "nReoccurring: " + frm.PreviousTicketSelect.value;
<i> </i>description += "nPrevious Ticket #: " + frm.PreviousTicketNumber.value;
<i> </i>//You can add the remaining fields
<i> </i>frm.Description.value = description;
}
I think there is a much easier and better way to do this than using the clipboard. If I understand you correctly you want all of the form data to be concatenated together and entered into a textarea. If that's the case, then just use the javascript to do that automatically!
Use the following function and you can either run it onclick of the button and have the info updated in the description field when the user clicks the button OR you could run the script onchange of any of the input field so that it is updated automatically.
[/QUOTE]
function updateDescription () {
frm = document.form1;
var description = ""
<i> </i>description += "Action Steps: " + frm.ActionSteps.value;
<i> </i>description += "nUsers Affected: " + frm.UsersAffected.value;
<i> </i>description += "nCurrent Phone number: " + frm.CurrentPhone.value;
<i> </i>description += "nAlt Contact: " + frm.AltPhone.value;
<i> </i>description += "nProcedure: " + frm.Procedure.value;
<i> </i>description += "nReoccurring: " + frm.PreviousTicketSelect.value;
<i> </i>description += "nPrevious Ticket #: " + frm.PreviousTicketNumber.value;
<i> </i>//You can add the remaining fields
<i> </i>frm.Description.value = description;
}
Dod you add a textarea named "description" to your form to receive the results?
You could set the content of the textarea to be selected once it is filled in and then all someone need do is press CTRL-C to then copy it to the clipboard. The clipboard is not accessible from web pages where proper security measures are implemented to protect the computer - also not all devices that can view web pages have a clipboard to start with.[/QUOTE]
Well, I had tested it on your original source code, so i was a little perplexed at first. There are two problems with your button:
1) The function (at least the one I wrote) does not take any parameters, so you can remove "copy" in the function call.
2) The function was not being called because you had the "copy" in item 1 enclosed in double quotes which were already inside double quotes.
[COLOR=DimGray]<input type="button" name="copyform" value="Copy to Clipboard" onclick= [COLOR=Red][B]"[/B][/COLOR] updateDescription ([COLOR=Blue][B]"[/B][/COLOR] copy[COLOR=Blue][B]"[/B][/COLOR] )[COLOR=Red][B]"[/B][/COLOR] >[/COLOR]
So, if you modified the function to take the parameter "copy" you should enclose it in single quotes.[/QUOTE]
Template += "Incident or Task Description: " + frm.Description.innerText;
Template += "Action Steps: " + frm.ActionSteps.value;
Template += "Users Affected: " + frm.UsersAffected.value;
Template += "Current Phone number: " + frm.CurrentPhone.value;
Template += "Alt Contact: " + frm.AltPhone.value;
Template += "Procedure: " + frm.Procedure.value;
Template += "Reoccurring: " + frm.PreviousTicketSelect.value;
Template += "Previous Ticket #: " + frm.PreviousTicketNumber.value;
I assume you mean like this:
<input type="button" name="copyform" value="Copy to Clipboard" onclick="updateDescription('copy')">[/QUOTE]
<input type="button" name="copyform" value="Copy to Clipboard" onclick="updateDescription()">
function updateDescription (frm)
{
var Template = ""
<i> </i>Template += "Incident or Task Description: " + frm.Description.value + "n";
<i> </i>Template += "Action Steps: " + frm.ActionSteps.value + "n";
<i> </i>Template += "Users Affected: " + frm.UsersAffected.value + "n";
<i> </i>Template += "Current Phone number: " + frm.CurrentPhone.value + "n";
<i> </i>Template += "Alt Contact: " + frm.AltPhone.value + "n";
<i> </i>Template += "Procedure: " + frm.Procedure.value + "n";
<i> </i>Template += "Reoccurring: " + frm.PreviousTicketSelect.value + "n";
<i> </i>Template += "Previous Ticket #: " + frm.PreviousTicketNumber.value + "n";
<i> </i>//You can add the remaining fields
<i> </i>frm.holdtext.value = Template;
}
<tr><td>HoldText<TEXTAREA ID="holdtext" name="holdtext" STYLE="height:150;width:162"></TEXTAREA></td><td><label>
<input type="button" name="copyform" value="Copy to Clipboard" onclick="updateDescription(this.form)"/>
And replace the "holdtext" and "Copy To Clipboard" fields like this
[/QUOTE]
<tr><td>HoldText<TEXTAREA ID="holdtext" name="holdtext" STYLE="height:150;width:162"></TEXTAREA></td><td><label>
<input type="button" name="copyform" value="Copy to Clipboard" onclick="updateDescription(this.form)"/>
I dont want to open a new topic, so might you guys can answer my question about a clipboard.
Is it possible to get the image from the clipboard using JS and paste it in the web page?[/QUOTE]
yes, you can ad multiple functin calls to an onclick evenet. But, it may not be the most efficient. For example, if validation fails you don't want to continue. So, it wouold make more sense to have one function, if it passes, to call the next function.
I still don't understand why you are copying this to the clipboard. I thought you were using the form to post the data. Also, you could set up a global variable to set the fields and preferences for validation instead of passing all that data in the MM_ValidateForm function.[/QUOTE]
yes, you can ad multiple functin calls to an onclick evenet. But, it may not be the most efficient. For example, if validation fails you don't want to continue. So, it wouold make more sense to have one function, if it passes, to call the next function.
I still don't understand why you are copying this to the clipboard. I thought you were using the form to post the data. Also, you could set up a global variable to set the fields and preferences for validation instead of passing all that data in the MM_ValidateForm function.[/QUOTE]
Check it out! Keep in mind, it only works in IE.
Any ideas how I can make it so the copy function will not run if errors are returned? I was thinking of an if else statement, but I am wondering what you think?[/QUOTE]
When write to new pape ? Please help me[/QUOTE]
I am not sure I understand the question...
I have attached the semi-completed version of my template tool. Still working on how to make it paste into a third party program.[/QUOTE]
Template += "Service Tag: " + frm.ServiceTag.value + "rn";
Template += "System Type: " + frm.SystemType.value + "rn";
Template += "OS: " + frm.OS.value + "rn";
Template += "***DTC Entitled*** " ;
Template += "DTC Order Number: " + frm.DTCOrderNumber.value + "rn";
Template += "Issue: " + frm.Issue.value + "rn";
Template += "Troubleshooting Steps: " + frm.TS.value + "rn";
Template += "HFN Tool Used: " + frm.HFNTool.value + "rn";
Template += "DC Session ID: " + frm.DCSessionID.value + "rn";
Template += "Cobro: " + frm.Cobro.value + "rn";
Template += "NTP: " + frm.NTP.value + "rn";
Template += "Heatcheck: " + frm.Heatcheck.value + "rn";
Template += "NonSat Reason: " + frm.NonSatReason.value + "rn";
frm.holdtext.value = Template;
Copied=frm.holdtext.createTextRange();
Copied.execCommand('copy');
alert('Information has been copied, right click and select paste or press ctrl+V to paste into Delta');
0.1.9 โ BETA 5.16