Copy link to clipboard
Copied
Hello.
On my PDF (created in Acrobat Pro), I currently have a button which copies selected items into a single field when pressed using the following script:
if(4==app.alert("Retrieve Introduction Items?",1,2)) {
var total = ""; for(var i=1; i<=30; i++){ if(this.getField("Box"+i).valueAsString != "Off") total+=this.getField("Text"+i).valueAsString+"\n";} this.getField("Sum1").value = total
}
The above script will pull the selected items through in a set order. However, is there a way for items to be coped into a list as they are selected, appearing in the target field in the order the user selects them?
thanks
Mark
You can do it using this function:
function mouseUpBox() {
var summaryTextField = this.getField("Sum1");
var summary = summaryTextField.valueAsString;
var textValue = this.getField(event.target.name.replace("Box", "Text")).valueAsString;
if (event.target.value=="Off") {
summary = summary.replace(textValue + "\r", "");
summaryTextField.value = summary;
} else summaryTextField.value+=textValue+"\r";
}
Add it as a doc-level script, and then call it from the Mouse Up event of each check-b
...Copy link to clipboard
Copied
That will require a more complex solution. You could add a code to each one of the check-boxes that adds the corresponding text field when is it clicked. But you would also need to do the reverse, ie. remove the text from the text field when the check-box is unticked.
I don't know how your file is set up, but if the user can edit the text in the text field after clicking the check-box that would not be possible, I think, or least much more complicated.
Copy link to clipboard
Copied
Thanks, that makes sense. The end user won't be editing the text, so that shouldn't be too much of an issue.
Copy link to clipboard
Copied
I think i've found a solution - just putting a caluclation script on the target box as follows'
var items = []; if (this.getField("Box28 ").value!="Off") items.push(this.getField("Text28").value); if (this.getField("Box29").value!="Off") items.push(this.getField("Text29").value);
// etc.
event.value = items.join("\n");
Copy link to clipboard
Copied
How is that different from what you originally had? I thought you wanted to merge them in the order in which the user selects them...
Copy link to clipboard
Copied
Yep - my mistake! I thought they were coming though in the order selected.
Copy link to clipboard
Copied
I Am Facing Same Issuue If Anyone Have Soultion Then Tell Me Please
Copy link to clipboard
Copied
You can do it using this function:
function mouseUpBox() {
var summaryTextField = this.getField("Sum1");
var summary = summaryTextField.valueAsString;
var textValue = this.getField(event.target.name.replace("Box", "Text")).valueAsString;
if (event.target.value=="Off") {
summary = summary.replace(textValue + "\r", "");
summaryTextField.value = summary;
} else summaryTextField.value+=textValue+"\r";
}
Add it as a doc-level script, and then call it from the Mouse Up event of each check-box.
Copy link to clipboard
Copied
Excellent - that works perfectly! Thank you - really appreciated.