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

Multiple fields (130+) and checking values.....

Engaged ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

Hi all,

 

I have a page with 132 fields all named "Dbc.1", "Dbc.2" etc. etc. - all the way thru until "Dbc.132" - and I have another set of (line specific) drop down fields named "Typeofdamageline1" and "Briefdescriptionline1", "Typeofdamageline2" and "Briefdescriptionline2" - all the way thru until "Typeofdamageline26" and "Briefdescriptionline26" .

 

What I am hoping to achieve is a way of checking the user-entered number value in any of the 132 "Dbc." fields (number range from 1-26) and that will then either hide, or reveal the associated line fields - so, for example - if the user enters say a "1" in any of the 132 "Dbc." fields, then the  "Typeofdamageline1" and "Briefdescriptionline1" fields are revealed, and say if the user enters subsequently say a "4" in any of the 132 "Dbc." fields, then "Typeofdamageline4" and "Briefdescriptionline4" field would also then be revealed - and so forth.

 

I have tried to use some form of table array, but these sadly are a bit of a mystery to me despite trying to understand them and make work! any assistance greatly appreciated....;-)

TOPICS
PDF forms

Views

377

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 , Jul 20, 2021 Jul 20, 2021

OK, then you can use this code as the custom calculation script of a (hidden) text field:

 

 

var rowsToShow = [];
for (var i=1; i<=132; i++) {
	var v = Number(this.getField("Dbc."+i).valueAsString);
	if (v!=0 && rowsToShow.indexOf(v)==-1) rowsToShow.push(v);
}

for (var i=1; i<=26; i++) {
	var bShow = rowsToShow.indexOf(i)!=-1;
	if (bShow) {
		this.getField("Typeofdamageline"+i).display = display.visible;
		this.getField("Briefdescriptionline"+i).display = display.visible;
	} else {
		this.getF
...

Votes

Translate

Translate
Community Expert ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

What should happen if they enter the same number multiple times?

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
Engaged ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

Hi try67,

 

In the instance that someone mistakenly adds a duplicate number (e.g. two "1" 's in any one of the 132 fields), then ideally there should still only be a 'reveal' on the line 1 fields (otherwise hidden)....the user shouldn't really be entering duplicate numbers, but humans being humans, I guess this is a very good point!

 

Thanks for the response, much 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
Community Expert ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

OK, then you can use this code as the custom calculation script of a (hidden) text field:

 

 

var rowsToShow = [];
for (var i=1; i<=132; i++) {
	var v = Number(this.getField("Dbc."+i).valueAsString);
	if (v!=0 && rowsToShow.indexOf(v)==-1) rowsToShow.push(v);
}

for (var i=1; i<=26; i++) {
	var bShow = rowsToShow.indexOf(i)!=-1;
	if (bShow) {
		this.getField("Typeofdamageline"+i).display = display.visible;
		this.getField("Briefdescriptionline"+i).display = display.visible;
	} else {
		this.getField("Typeofdamageline"+i).display = display.hidden;
		this.getField("Briefdescriptionline"+i).display = display.hidden;
		this.resetForm(["Typeofdamageline"+i, "Briefdescriptionline"+i]); // disable this line if you don't want the fields to be cleared when hidden
	}
}

 

Edit: small bug fixed in the code.

 

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
Engaged ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

LATEST

Hi try67,

 

Perfect, works like a charm - thankyou so much for that, brilliant! ;-).

 

 

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