• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Copying items into a single field in order they are selected

Community Beginner ,
Apr 17, 2021 Apr 17, 2021

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

TOPICS
Create PDFs , PDF forms

Views

419

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 17, 2021 Apr 17, 2021

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

...

Votes

Translate

Translate
Community Expert ,
Apr 17, 2021 Apr 17, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2021 Apr 17, 2021

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.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2021 Apr 17, 2021

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");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2021 Apr 17, 2021

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

Yep - my mistake! I thought they were coming though in the order selected.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

I Am Facing Same Issuue If  Anyone Have Soultion Then Tell Me Please 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2021 Apr 17, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

LATEST

Excellent - that works perfectly! Thank you - really appreciated.   

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines