Expand my Community achievements bar.

SOLVED

Show/hide Subform based on Numeric field value

Avatar

Level 1

Hi All,


I have created my first form in LiveCycle Designer, but got stuck with the coding. Any help would be greatly appreciated.

In the attached form, based on the Numeric Field value 'Total points' (Calculated from user input),I want two things to happen,

The text field 'level' should show different text according to the points,

  •   Points less than 10 is "Beginner",
  •   10-14 is "Intermediate"

          and like that...

If total points is less than 10, 'Beginners course' and 'Language' DropDownList should appear.

Is there any way to achieve this? I tried assigning "If" "else" statement, but it is not working. I looked into the previous threads, but couldn't find anything based on numeric value.

Looking for some help,
R

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The attached satisfies your requirements. The following JavaScript on the TextField1 calculate event drives it.

// form1.#subform[0].TextField1::calculate - (JavaScript, client)

if (NumericField1.rawValue != 0) {
    if (NumericField1.rawValue < 10) {
        DropDownList1.presence = "visible";
        DropDownList2.presence = "visible";
        this.rawValue = "Beginner";
    }
    else {
        DropDownList1.presence = "hidden";
        DropDownList2.presence = "hidden";
        if (NumericField1.rawValue < 15) {
            this.rawValue = "Intermediate";
        }
        else {
            this.rawValue = "";
        }
    }
}

Steve

View solution in original post

10 Replies

Avatar

Correct answer by
Former Community Member

The attached satisfies your requirements. The following JavaScript on the TextField1 calculate event drives it.

// form1.#subform[0].TextField1::calculate - (JavaScript, client)

if (NumericField1.rawValue != 0) {
    if (NumericField1.rawValue < 10) {
        DropDownList1.presence = "visible";
        DropDownList2.presence = "visible";
        this.rawValue = "Beginner";
    }
    else {
        DropDownList1.presence = "hidden";
        DropDownList2.presence = "hidden";
        if (NumericField1.rawValue < 15) {
            this.rawValue = "Intermediate";
        }
        else {
            this.rawValue = "";
        }
    }
}

Steve

Avatar

Level 1

Thank you so much Steve. It worked.

I am sorry. This might be a dumb question to ask. In the code, could you please explain the first part, "(NumericField1.rawValue != 0)".

Since, I assigned the rest of the code, which obviously didn't work. I am new to coding.

Are there any coding tutorial available for LiveCycle Designer for newbies like me???

Thanks a lot

R

Avatar

Former Community Member

No dumb questions. The expression 'NumericField1.rawValue != 0' is used to test the value of NumericField1, in this case 0 (zero), which is the default value of a numeric field. I want to apply logic if the field is not 0, only.

Steve

Avatar

Level 10

Not really specific to LiveCycle but there are lots of javascript tutorials around. They're all pretty much geared towards the web but you can still learn the basics.

Check out http://www.w3schools.com/

Avatar

Level 10

Oh yeah, and that book - it's great!

Avatar

Level 1

Hi Steve,


Sorry for bugging yor further. Another question. I want the changes to happen only after the rating points reaches '10' .


Is there any way to assign the condition to our code?

Thank you
R

Avatar

Level 1

Got it...

I have added another 'if" "else" statement to the code and it works as I wanted...

Thank you Steve.

R

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