Expand my Community achievements bar.

SOLVED

Javascript help

Avatar

Former Community Member

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
Former Community Member

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

2 Replies

Avatar

Correct answer by
Former Community Member

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

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----