Expand my Community achievements bar.

SOLVED

Count the number of times a field is filled

Avatar

Former Community Member

Help!!!

I am building a form with 10 number fields named task1, task2, task3, etc. Different users may or may not use all of these fields. For example, a user may only fill in 7 of these 10 number fields, while another user may only use 5. I need the form to count the number of task* fields have been filled in, and place that number into a number field named TotalTasks.

Any help is appreciated!

Gene-O

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Ok here is a fixed version. The code on each of thise task fields was

expecting there to be a Page2 subform. I renmaed the subform to Page2 and that caused issues on a couple of

fields on Page1. So I updated the code on Responsibility and Disciplinary fields as well. All seems to b working now.

Paul

View solution in original post

7 Replies

Avatar

Former Community Member

Here is an example ....I put the code on the exit event of each Task field. If there was an event that would fire after they were finished with the tasks then it woudl make sense to do it there. It also will decrement the counter if the user changes their mind and they blank out the field.

Paul

Avatar

Former Community Member

Paul,

I did a copy/paste to put your code into the exit of each of my boxes in JavaScript at Client. But it doesn't work. I don't know what I am doing wrong. The only difference I found is that my boxes are number fields and yours are text fields. Any ideas?

Thanks!

Gene-O

Avatar

Former Community Member

Also,

When I open the form, the Total box has nothing in it. When I enter a value into any of the task boxes, the Total box returns a value of 0.

Nothing seems to change this.

Thanks!

Gene-O

Avatar

Former Community Member

My guess is that the names of the fields don't match. Can you post your form so we can see what is wrong?

Paul

Avatar

Correct answer by
Former Community Member

Ok here is a fixed version. The code on each of thise task fields was

expecting there to be a Page2 subform. I renmaed the subform to Page2 and that caused issues on a couple of

fields on Page1. So I updated the code on Responsibility and Disciplinary fields as well. All seems to b working now.

Paul

Avatar

Former Community Member

Paul,

You are "smarter than your average bear". Thanks so much for the help!!!!!!!

Gene-O

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