Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Javascript help

Avatar

Level 2

Hi I am concatinating numerous fields in to one t

show it one filed in the form as below(Steve has helped me on this).

if

(xfa.resolveNode("Page7.Q2a01_TX").rawValue.isNull) {

str

= str;

}

else

{

str

= xfa.resolveNode("Page7.Q2a01_TX").rawValue;

}

if

(xfa.resolveNode("Q2a02_TX").isNull) {

str

= str + "";

}

else

{

str

= str + "\n" + xfa.resolveNode("Q2a02_TX").rawValue;

}

if

(xfa.resolveNode("Q2a03_TX").isNull) {

str

= str + "";

}

else

{

str

= str + "\n" + xfa.resolveNode("Q2a03_TX").rawValue; so on till 40 ...

the RESULT now is   as

Testing for question1

Testing for question2

Testing for question3

Testing for question4

but now i want to add "Q1" , "Q2" etc before by modifying as below which is understandbily not correct as

if

(xfa.resolveNode("Page7.Q2a01_TX").rawValue.isNull) {

str

= str;

}

else

{

str

= "Q1" +  xfa.resolveNode("Page7.Q2a01_TX").rawValue;

}

if

(xfa.resolveNode("Q2a02_TX").isNull) {

str

= str + "";

}

else

{

str

= str + "\n" +"Q2"+ xfa.resolveNode("Q2a02_TX").rawValue;

}

if

(xfa.resolveNode("Q2a03_TX").isNull) {

str

= str + "";

}

else

{

str

= str + "\n" +"Q3"+  xfa.resolveNode("Q2a03_TX").rawValue; so on till 40 ...

BUT THE RESULT NOW WOULD BE

Q1 Testing for question1

Q1 Q2 Testing for question2

Q1 Q2 Q3 Testing for question3

Q1 Q2 Q3 Q4 Testing for question4

How can i just make the script to say

Q1 Testing for question1

Q2 Testing for question2

Q3 Testing for question3

Q4 Testing for question4

I am a novice in JS ,  can somebody haelp me on this.

Thanks In advance

De1209

1 Accepted Solution

Avatar

Correct answer by
Level 10

I cannot find the original form but is this the result you want?

Untitled.png

Where...

// form1.page1.subform1.tf::calculate - (JavaScript, client)

var str = "";

if (form1.page1.subform1.nf1.isNull) {

  str = str;

}

else {

  str = "Q1 " + form1.page1.subform1.nf1.rawValue + "\n";

}

if (form1.page1.subform1.nf2.isNull) {

  str = str + "\n";

}

else {

  str = str + "Q2 " + form1.page1.subform1.nf2.rawValue + "\n";

}

if (form1.page1.subform1.nf3.isNull) {

  str = str + "\n";

}

else {

  str = str + "Q3 " + form1.page1.subform1.nf3.rawValue + "\n";

}

Steve

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

I cannot find the original form but is this the result you want?

Untitled.png

Where...

// form1.page1.subform1.tf::calculate - (JavaScript, client)

var str = "";

if (form1.page1.subform1.nf1.isNull) {

  str = str;

}

else {

  str = "Q1 " + form1.page1.subform1.nf1.rawValue + "\n";

}

if (form1.page1.subform1.nf2.isNull) {

  str = str + "\n";

}

else {

  str = str + "Q2 " + form1.page1.subform1.nf2.rawValue + "\n";

}

if (form1.page1.subform1.nf3.isNull) {

  str = str + "\n";

}

else {

  str = str + "Q3 " + form1.page1.subform1.nf3.rawValue + "\n";

}

Steve