Changing the value of a textfield depending on choices in dropdown field

New Here ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Hi all,

I'm currently working on a multipage Dokument, where the user starts with a "Setup Page" and depending on the choices on that page certain Templates are spawned and some values on these spawned pages are to be changed and some fields are set to be visible or invisible.

My issue is that one function doesn't seem to actually "care" about the current value of the Field "Herz"

 

The Functon is called amongst others on a button press.

Am I forgetting about something?

 

function D530_Herz()
{

// Herzphantom oder Mini Jasczcak-Phantom (D530c)

if(this.getField("Herz").value == "H")
{
this.getField("Page3_D530_Tomo_00a").value = "Herzphantom, Tomoauflösungsphantom mit Tc99m";

this.getField("Page3_D530_Tomo_01a").value = "Typ: Herzphantom";

this.getField("Page3_D530_Tomo_04a").value = "Defekt sichtbar?";
this.getField("Page3_D530_Tomo_05a").value = "Artefakte sichtbar?";

this.getField("Page3_D530_Tomo_04c_J").display = display.hidden;
this.getField("Page3_D530_Tomo_04d_J").display = display.hidden;
this.getField("Page3_D530_Tomo_05c_J").display = display.hidden;
this.getField("Page3_D530_Tomo_05d_J").display = display.hidden;
this.getField("Page3_D530_Tomo_04c_C").display = display.visible;
this.getField("Page3_D530_Tomo_04d_C").display = display.visible;
this.getField("Page3_D530_Tomo_05c_C").display = display.visible;
this.getField("Page3_D530_Tomo_05d_C").display = display.visible;

this.getField("Page3_D530_Tomo_06a").display = display.hidden;

this.getField("Page3_D530_AbMa_00a").display = display.visible;
this.getField("Page3_D530_AbMa_01b").display = display.visible;
this.getField("Page3_D530_AbMa_01c").display = display.visible;
this.getField("Page3_D530_AbMa_02a").display = display.visible;
this.getField("Page3_D530_AbMa_02b").display = display.visible;
this.getField("Page3_D530_AbMa_02c").display = display.visible;
this.getField("Page3_D530_AbMa_03a").display = display.visible;
this.getField("Page3_D530_AbMa_03b").display = display.visible;
this.getField("Page3_D530_AbMa_03c").display = display.visible;
}
else
{
this.getField("Page3_D530_Tomo_00a").value = "Volumenphantom, Tomoauflösungsphantom mit Tc99m";

this.getField("Page3_D530_Tomo_01a").value = "Typ: Small Flangeless SPECT Phantom, Model ECT/SM/P (L: 23cm x 😧 115,3cm )";

this.getField("Page3_D530_Tomo_04a").value = "Inhomogenität (visuelle prüfung)";
this.getField("Page3_D530_Tomo_05a").value = "Kontrast (Anzahl der Kugeln)";

this.getField("Page3_D530_Tomo_04c_J").display = display.visible;
this.getField("Page3_D530_Tomo_04d_J").display = display.visible;
this.getField("Page3_D530_Tomo_05c_J").display = display.visible;
this.getField("Page3_D530_Tomo_05d_J").display = display.visible;
this.getField("Page3_D530_Tomo_04c_C").display = display.hidden;
this.getField("Page3_D530_Tomo_04d_C").display = display.hidden;
this.getField("Page3_D530_Tomo_05c_C").display = display.hidden;
this.getField("Page3_D530_Tomo_05d_C").display = display.hidden;

this.getField("Page3_D530_Tomo_06a").display = display.visible;

this.getField("Page3_D530_AbMa_00a").display = display.hidden;
this.getField("Page3_D530_AbMa_01b").display = display.hidden;
this.getField("Page3_D530_AbMa_01c").display = display.hidden;
this.getField("Page3_D530_AbMa_02a").display = display.hidden;
this.getField("Page3_D530_AbMa_02b").display = display.hidden;
this.getField("Page3_D530_AbMa_02c").display = display.hidden;
this.getField("Page3_D530_AbMa_03a").display = display.hidden;
this.getField("Page3_D530_AbMa_03b").display = display.hidden;
this.getField("Page3_D530_AbMa_03c").display = display.hidden;
}
}

 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, PDF forms

Views

59

Likes

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
Most Valuable Participant ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Do you mean it always defaults to the "else" clause? If so, maybe the value of this field is not what you think it is, for some reason... Try adding this line at the top of your function:

app.alert(this.getField("Herz").value.toSource());

And see what appears in the alert window when it is executed. If it's not (new String("H")) then there's an issue.

Likes

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 ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

hi,

in the meantime I figured out that it doesn't do anything.

Adding your suggestion just before the if-clause just confirmes that for some reason the function is never called, besides being calles as D530_Herz(); in the Script for the button

 

here is the button-script. it seems there is an issue preventing multiple of my functions not to be called.

I'm since the PageSpawn-Function is running propperly, I'll have a close lok on that one next

 

//======================================================================================================================
// löschen alter Seiten, außer Seite 1

DelPageBut1();

//======================================================================================================================
// Sperren der SPage Auswahlfelder

LockSPage();

//======================================================================================================================
// Spawnen der nötigen Seiten gemäß Systemtyp

PageSpawn();

//======================================================================================================================
// Co57 Phantom vorhanden, Felder ausblenden.

Co57();

//======================================================================================================================
// LinRes auswahl (NEMA oder 4Q)

NEMA();

//======================================================================================================================
// Anpassen der RS / TG Werte für die Uniformität

UNIF_RSTG_Mill();

//======================================================================================================================
// Herzphantom oder Mini Jasczcak-Phantom (D530c)

D530_Herz();

//======================================================================================================================
// Einstellen des NM Dokumententitels

NM_DocTitel();

//======================================================================================================================
// Ändern von Feldern für die CT-Seitigen Prüfungen

CT_DocSettings();

//======================================================================================================================
// Anpassen der Sollwerte für die COR je nach Systemtyp

NM_COR_Specs();

//======================================================================================================================
// Anpassen der Sollwerte für die VQC je nach Systemtyp

NM_VQC_Specs();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Background-Messung der D530c.

NM_530_BKG_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Ausbeute-Messung der D530c.

NM_530_AUSB_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Tomo-Messung der D530c.

NM_530_Tomo_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Background-Messung der D750b.

NM_750_BKG_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Ausbeute-Messung der D750b.

NM_750_AUSB_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Ortsauflösungs-Messung der D750b.

NM_750_OA_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Background-Messung.

NM_BKG_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Aubeute-Messung.

NM_AUSB_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Uniformity-Messung.

NM_UNIF_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der LinRes-Messung.

NM_LinRes_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der GK Abbildungsmaßstab-Messung.

NM_GKAbMa_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der GK Ortsauflösung-Messung.

NM_GKOA_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der Jaszczak-Messung.

NM_JAS_ABN();

//======================================================================================================================
// Ändern von Feldern für die Abnahme der DIN-Phantom-Messung.

NM_DIN_ABN();

//======================================================================================================================
// Anpassen der Seitenzahlen.

PageNumbers();

//======================================================================================================================
// Aublenden von Feldern, die für Single-Head-Kameras nicht benötigt werden.

SH_FelderAusblenden();

//======================================================================================================================
//ENDE

 

Likes

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
Most Valuable Participant ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

My guess is one of the earlier functions is causing an error, which stops the script. As mentioned, check the JS Console for error messages.

Likes

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
Adobe Community Professional ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Check the console for errors.

Likes

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
Most Valuable Participant ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Here's a suggestion to make your code easier to maintain, and to spot issues with incorrect field names:

 

function D530_Herz() {

	// Herzphantom oder Mini Jasczcak-Phantom (D530c)

	var fields1 = ["Page3_D530_Tomo_04c_J", "Page3_D530_Tomo_04d_J", ...];
	var fields2 = ["Page3_D530_Tomo_04c_C", "Page3_D530_Tomo_04d_C", ...];

	if (this.getField("Herz").value == "H") {
		this.getField("Page3_D530_Tomo_00a").value = "Herzphantom, Tomoauflösungsphantom mit Tc99m";
		this.getField("Page3_D530_Tomo_01a").value = "Typ: Herzphantom";
		this.getField("Page3_D530_Tomo_04a").value = "Defekt sichtbar?";
		this.getField("Page3_D530_Tomo_05a").value = "Artefakte sichtbar?";
		
		for (var i in fields1) {
			var f = this.getField(fields1[i]);
			if (f==null) {console.println("ERROR: " + fields1[i]); continue;}
			f.display = display.hidden;
		}
		for (var i in fields2) {
			var f = this.getField(fields2[i]);
			if (f==null) {console.println("ERROR: " + fields2[i]); continue;}
			f.display = display.visible;
		}
	} else {
		this.getField("Page3_D530_Tomo_00a").value = "Volumenphantom, Tomoauflösungsphantom mit Tc99m";
		this.getField("Page3_D530_Tomo_01a").value = "Typ: Small Flangeless SPECT Phantom, Model ECT/SM/P (L: 23cm x  115,3cm )";
		this.getField("Page3_D530_Tomo_04a").value = "Inhomogenität (visuelle prüfung)";
		this.getField("Page3_D530_Tomo_05a").value = "Kontrast (Anzahl der Kugeln)";
		
		for (var i in fields1) {
			var f = this.getField(fields1[i]);
			if (f==null) {console.println("ERROR: " + fields1[i]); continue;}
			f.display = display.visible;
		}
		for (var i in fields2) {
			var f = this.getField(fields2[i]);
			if (f==null) {console.println("ERROR: " + fields2[i]); continue;}
			f.display = display.hidden;
		}
	}
}

Likes

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 ,
Mar 31, 2020 Mar 31, 2020

Copy link to clipboard

Copied

LATEST

Hi all,

thanks for the help.

It turns out that I had a typo in the PageSpawn function and I overlooked the message in the console.

Likes

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