Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Count fields fn is excluding radio buttons
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Count fields fn is excluding radio buttons

 Post Reply Post Reply
Author
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Topic: Count fields fn is excluding radio buttons
    Posted: 20 Sep 2016 at 4:06pm
Greetings.  I'm trying to step through an array of fields and get a count of the empty fields.  It's working for the text fields but skipping the radio buttons.

Document-level function:

function SPHRR1(aNames)
{
var fieldValue;
var nCount = 0;
for (i = 0; i < aNames.length; i++)
{
 oField = this.getField(aNames);
 if(oField.value == "") nCount++;
}
return nCount;
}

The array is defined at document level with all the other form's variables.  The definition of the variables is named aaaVariables so it will appear at the top of the list of Document-level goodies.

var aReqSPHRR1all = new Array("sphrr1_s2_q1_rb","sphrr1_s2_q2_rb","sphrr1_s2_q3_rb","sphrr1_s2_q4_rb","sphrr1_s2_q5_rb","sphrr1_s2_q6_rb","sphrr1_s2_q7_rb","sphrr1_s2_q8a","sphrr1_s2_q8b","sphrr1_s3_q2_rb","sphrr1_s3_q3_rb","sphrr1_s3_q4","sphrr1_s3_q5_rb","sphrr1_s3_q5a_rb","sphrr1_s3_q5c","sphrr1_s2_3_q6","sphrr1_s2_3_q7")

There's just a simple custom calculation script in a hidden field on the form to grab the count of fields in the array which have no value. 

event.value = SPHRR1(aReqSPHRR1all);

It returns 6 for the event.value, which is the number of text fields in the array.  I expect to see a count of 17 if all fields are left blank.

I temporarily added this to the Document-level function to make sure it was indeed only recognizing the text fields and not a coincidence that the returned count was 6: 
Instead of  if(oField.value == "") nCount++;
temporarily used if(oField.type=="radio" && oField.value == "") nCount++;
It returned 0 (zero) for the count, though all fields were blank.

Elsewhere on the form, I can check whether a radio button's value is "", "Y", "N", etc. and it works.  Could somebody please advise me as to why it doesn't work in the function and what can be done to recognize not only the blank text fields but also the blank radio button fields in the array?

Doing this through brute force and ignorance...

Thank you,
~morrison

Back to Top
Sponsored Links


Back to Top
Rob Lyman View Drop Down
New Member
New Member
Avatar

Joined: 12 May 2015
Location: Chicago
Points: 25
Post Options Post Options   Quote Rob Lyman Quote  Post ReplyReply Direct Link To This Post Posted: 21 Sep 2016 at 10:09pm
Can you clarify what you mean by a 'blank' radio button? With radio button controls, usually one (and only one) out of the set of button controls is selected, and would therefore be reported as the radio button's (non-blank) value. Is a 'blank' radio button one where none of the button controls are selected?
Rob Lyman
Software Engineer
http://www.datalogics.com
Back to Top
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Posted: 22 Sep 2016 at 2:35pm
Never mind, but thank you.  I figured it out.  Had to check for radio buttons being "Off" not "" in order for them to be included in the count.

(By "blank", I meant no selection made, the value equaling "")

Tweaked the one line to now read as follows:
 if(oField.value=="" | oField.value=="Off") nCount++;
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.016 seconds.