Below Code works great but counter still shows 1 even there is no empty filled

Avatar

Avatar

Karwan_Mawlood

Avatar

Karwan_Mawlood

Karwan_Mawlood

16-06-2016

Below is the code to get the empty filleds (counter);

form1.Page1.notification.NumericField1::ready:layout - (FormCalc, client)

var FilledRows = 0

for i = 0 upto Body.Table1.Row1.instanceManager.count - 1 do

     if (Body.Table1.Row1[i].drp_names eq null) then

          FilledRows = FilledRows + 1;

          this.rawValue = FilledRows;

     endif

endfor

the code in Javascript to check if the value of the counter is zero

form1.Page1.save_as::click - (JavaScript, client)

   if (notification.NumericField1.rawValue == 0){

  xfa.host.messageBox("This will save your form as PDF form, means you can edit later once more","Save As Form",3,0);

  app.execMenuItem("SaveAs");}

else

{xfa.host.messageBox("You have : " + notification.NumericField1.rawValue + " empty highlighted fields","Empty Fields",3,0);}

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

radzmar

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

385

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

385

Correct Answer

485
radzmar
MVP

20-06-2016

If FormCalc you should assign a fields value at the very end of your script, otherwise i may be overwritten by a arithmethical or boolean result of the script itself.

var FilledRows = 0

for i = 0 upto Body.Table1.Row1.instanceManager.count - 1 do

    if (Body.Table1.Row1[i].drp_names.inNull eq 1) then

          FilledRows = Sum(FilledRows, 1)

    endif

endfor

$ = FilledRows;

Answers (4)

Answers (4)

Avatar

Avatar

Karwan_Mawlood

Avatar

Karwan_Mawlood

Karwan_Mawlood

20-06-2016

perfectly working now after assigning the value to a filled since my code was overwriting it self, it was making filledRows = 0 if only the last row was not null even the others are null. but now after assigning it does not do that Thanks alot radzmar

and for future help for our dear users below is the working code in JAVASCRIPT and FORMCALC:

In Javascript

// in Javascript

var notempty = 0;

var rowcount = Body.Table1.Row1.instanceManager.count;

for (var i=0;i<rowcount;i++){

   if (xfa.resolveNode("Body.Table1.Row1[" + i + "]").drp_names.rawValue == null)

{

notempty = notempty + 1;}

}

this.rawValue = notempty;

In Formcalc

// in formcalc

var FilledRows = 0 

for i = 0 upto Body.Table1.Row1.instanceManager.count - 1 do 

    if (Body.Table1.Row1[i].drp_names.inNull eq 1) then 

          FilledRows = Sum(FilledRows, 1) 

    endif 

endfor 

$ = FilledRows;

Avatar

Avatar

Karwan_Mawlood

Avatar

Karwan_Mawlood

Karwan_Mawlood

19-06-2016

hi dear,

I managed to find the code myself I started again but this time from Javascript not formcalc and it worked fine now below is the code for future help you will create one numerical field and put this code in layout ready

// Null check for expanding table and rows - Name and give how many are null

var notemptyrows = 0;

for (i=0;i<Body.Table1.Row1.instanceManager.count;i++){

   if (xfa.resolveNode("Body.Table1.Row1[" + i + "]").drp_names.rawValue == null)

{notemptyrows = notemptyrows + 1;

this.rawValue = notemptyrows;}

else

{this.rawValue = 0;}}

Avatar

Avatar

Karwan_Mawlood

Avatar

Karwan_Mawlood

Karwan_Mawlood

19-06-2016

Hi dear

thanks for your time, here it's my form, see when you add rows the number of empty fields are increasing in the numericalcell I have created. but when you select all the dropdowns and there is no null dropdown the numerical cell still says there is 1 empty dropdown Please take a look and tell me what I am doing wrong .

https://we.tl/ZRHiZ9xIc1

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

268

Correct Answer

371

Avatar

_Bruce_Robertson

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

268

Correct Answer

371
_Bruce_Robertson
MVP

17-06-2016

Hi Karwan,

Your code looks ok to me, is it possible you can upload your form to a file sharing site and post a link to it in this thread so we can have a look?

Regards

Bruce