Count checkboxes with 500+ unique names

The form I am using a simple checklist, that was generated in Word and converted to a form in Acrobat, which is why it has so many unique field names.
I found the following solution but I am looking for something more elegant and that doesn't require me to enter each unique name.
I added the following script to the  document level function :
function CountCheckBoxes(aFieldNames) {
// count field names that have been selected
var count = 0;
var cField = "";
// loop through array of field names
for(i = 0; i < aFieldNames.length; i++) {
// for field names with a value of not Off increment counter
if(this.getField(aFieldNames[i]).value != "Off") count++;
} // end loop of field names
// return count
return count;
} // end CountCheckBoxes
I also added text field with the following custom calculation script:
// var define field names to be tested
var aFields = new Array('uniquename', 'anothername...etc');
// count field names that have been selected
event.value = CountCheckBoxes(aFields);
In order to quickly add 500+ field names, I use a temporary field to grab all the field value by using Pick under Calculate sum. I then cut and paste them into notepad and replace the
with
then a copy the full text into the above code replacing 'uniquename', 'anothername...etc'
It works but it is lengthy and I hoping a code guru might have a smarter solution.

That's the former, not the latter...
Anyway, you can use this code, then:
var totalCheckboxes = 0;
var totalChecked = 0;
for (var i=0; i<this.numFields; i++) {
    var f = this.getField(this.getNthFieldName(i));
    if (f==null) continue;
    if (f.type=="checkbox") {
        totalCheckboxes++;
        if (f.value!="Off") {
            totalChecked++;
At the end totalCheckBoxes will contain the total number of check-boxes in the file, and totalChecked the number of the checked boxes out of them.

Similar Messages

  • Counting Checkboxes with different Names

    I have a form that I am creating in Livecycle Designer 8.0 that has 100 checkboxes that the user selects from. I would like to have a field that counts how many check boxes are checked. What is the easiest way to do this?
    Also, Do I have to add each field individually or is there a way to select them all and insert to the formula at once?
    Thanks!

    Big thanks out to Paul Guerette for helping me write the script for this. He gave me an option to do it as an exit event of the pages or on a button click. Here is the code for the button click:
    - form1.Order_Page.Button1::click: - (JavaScript, client) ---
    form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue = 0;
    //app.alert("Page1 Exit Event fired!!!!");
    //Get total number of element on Page 1 of the form
    var allChildElements = form1.Course_Selection_Subform1.Course_Selection_Page_1.nodes;
    var intNumElements = allChildElements.length;
    //app.alert("The number of elements is: " + intNumElements);
    //Loop through all the objects on Page1
    for(j=0; j< intNumElements;j++){
    //set the 1st object to a variable name
    currentElement = allChildElements.item(j);
    //if the object is a field then test to see if it is a checkbox
    if(currentElement.className == "field") {
    //app.alert(currentElement.ui.oneOfChild.className);
    // is it a checkbox?
    if (currentElement.ui.oneOfChild.className == "checkButton"){
    //Is the checkbox checked?
    if (currentElement.rawValue == "1"){
    //increment the Course_Quantity field
    form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue = form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue + 1;
    //app.alert("Page2 Exit Event fired!!!!");
    //Get total number of element on Page 1 of the form
    var allChildElements = form1.Course_Selection_Subform2.Course_Selection_Page_2.nodes;
    var intNumElements = allChildElements.length;
    //app.alert("The number of elements is: " + intNumElements);
    //Loop through all the objects on Page1
    for(j=0; j< intNumElements;j++){
    //set the 1st object to a variable name
    currentElement = allChildElements.item(j);
    //if the object is a field then test to see if it is a checkbox
    if(currentElement.className == "field") {
    //app.alert(currentElement.ui.oneOfChild.className);
    // is it a checkbox?
    if (currentElement.ui.oneOfChild.className == "checkButton"){
    //Is the checkbox checked?
    if (currentElement.rawValue == "1"){
    //increment the Course_Quantity field
    form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue = form1.Order_Page.Product_Table.Row3.Course_Quantity.rawValue + 1;

  • Multiple AD with same unique name

    Our requirement is configure 2 AD servers with GRC ( version 10). But the tricky part is around 300 users in both the domians are same. ef.
    Domain  \ User name
    NBC \ test
    PBS \ test
    Now I have to integrate these 2 domains in ABAP.  My problem is once I hook NBC AD it will create test and if I hook up PBS it will not create test.  But I need that too.  (may be I want pass say test1 instead of test) Can this be doable?  How?
    Kedar

    Our requirement is...
    Yep, had this requirement as well.
    All these various user name collisions and worse is different IDs for the same person can be solved relatively easily by IdM.
    But best practice is still to remove the collisions and use unique IDs. Same goes for deleting users (dont do it).
    Good luck.
    Cheers,
    Julius

  • Managing Internet clients with non unique names

    I've got a wee complication which revolves around the fact the majority clients I am looking to deploy to are workgroup clients which have non-unique netbios/short names. 
    So when trying to manage said clients when looking at the Assets / Devices tab they for all intensive purposes appear identical - until I look at the properties of each item and look at the Resource Name - which will show the FQDN fo said machine.
    If I was able to select Resource name as a viewable field in the view this would fix my problem. Unfortunately all machines currently have the same Workgroup set so just displaying the "Domain" field will not suffice.
    Has anyone run into this issue and what can be done to work around it short of renaming all my intended clients? I've seen mention of creating your own Console custom nodes however this looks rather hairy.
    Any thoughts are greatly appreciated. Cheers.

    Also, I don't think that it will really help you, because the Devices
    node is build on the SMS_CombinedDeviceResources class and that WMI class simply doesn't contain the
    Resource Name property.
    In this case it would mean creating a whole new node in the console. Probably using a Query, or Report is the most simple and best workaround.
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • Create a temp file with unique name?

    Hi all,
    I need to create a temporary IResource in a KM repository. Is there any equivalent to the java.io.File.createTempFile() method to create a IResource with a unique name that isn't already there?
    Thanks for your help,
    Markus

    Hi Markus,
    AFAIK there is no such method.
    However, you can implement it yourself by using a simple rule,
    such as to concat a timestamp ((new Date()).getTime()) to the created resource's name.
    For an even more robust rule, you can also concat the creator's login-name.
    Hope that helps,
    Yoav.

  • Counting Checkboxes

    I'm not that familiar with JavaScript... I have a form I want to make with 18 questions, and each question has three checkboxes with the same name, and each checkbox has a unique export value. Only one checkbox per question can be selected. One box is for yes, another no, and another for n/a.
    I'm trying to figure out how to look at all the checkboxes in the form and then return the number of yes, no, and n/a selected respectively in separate text boxes. I can't quite make sense of how to do it.

    Are you trying to count both the "Yes" and "No" check boxes together or just count the specific selected answer?
    For "Yes":
    var counter = 0;
    for (var i =0 ; i < this.numFields ; i++) {
    var q = this.getField(this.getNthFieldName(i));
    if (q.type == "checkbox") {
    if (q.value.toLowerCase() = "yes") {
        counter++;
         } // yes value;
       } // check box;
    } // end field loop;
    event.value = counter;

  • Duplicating or creating MC with a new names

    Help me please! I need to duplicate or create new movie clips
    with new unique names generated in loop.
    In AS2.0 it was done with construction like this:
    for(i=0; i=100; i++){
    createEmptyMovieClip("MC"+i, 1); //or
    duplicateMovieClip(MC,"NewMC"+1,); for duplicating
    I need analog of this. Help me please!!!

    :

  • Move files and create unique name something wrong with my script

    Can you see where I might be going wrong here?
    Just trying to create a unique name if something exists.
    In English.
    Move file to the destinationFolder
    Item exists in destinationFolder > Move file in the destination folder to the fake Trash > If it exists in fakeTrash too then give it a new name an ending of_a.psd then out it in the trash
    Once thats done move start file to the destination folder.
    Currently when the file exists in the destination folder and in the trash, I get the prompt then the error
    error "System Events got an error: Can’t get disk item \"NN_FR10WW06290PK3LE.psd\"." number -1728 from disk item "NN_FR10WW06290PK3LE.psd"
    set fileMatrix to {¬
              {folderName:"BHS", prefixes:{"BH", "SM", "AL"}}, ¬
              {folderName:"Bu", prefixes:{"BU"}}, ¬
              {folderName:"Da", prefixes:{"ES"}}, ¬
              {folderName:"Di", prefixes:{"DV"}}, ¬
              {folderName:"Do", prefixes:{"DJ", "RA"}}, ¬
              {folderName:"In", prefixes:{"GT", "CC"}}, ¬
              {folderName:"Fr", prefixes:{"FR"}}, ¬
              {folderName:"No", prefixes:{"NN"}}, ¬
              {folderName:"Ma", prefixes:{"MA", "MF", "FI", "MC", "MH", "MB"}}, ¬
              {folderName:"Pr", prefixes:{"PR"}}, ¬
              {folderName:"To", prefixes:{"TM15", "TM11", "TM17"}}, ¬
              {folderName:"Wa", prefixes:{"WA"}}, ¬
              {folderName:"Se", prefixes:{"SE"}}}
    tell application "Finder"
              set theHotFolder to folder "Hal 9000:Users:matthew:Pictures:HotFolderDone"
              set foldericon to folder "Hal 9000:Users:matthew:Pictures:Icons:Rejected Folder Done"
              set fakeTrash to folder "Hal 9000:Users:matthew:FakeTrash"
      ---here
              repeat with matrixItem in fileMatrix -- look for folder
                        set destinationFolder to (folders of desktop whose name starts with folderName of matrixItem)
                        if destinationFolder is not {} then -- found one
                                  set destinationFolder to first item of destinationFolder -- only one destination
                                  set theFolderName to name of destinationFolder
                                  repeat with aPrefix in prefixes of matrixItem -- look for files
                                            set theFiles to (files of theHotFolder whose namestarts with aPrefix) as alias list
                                            if theFiles is not {} then repeat with startFile intheFiles -- move files
                                                      try
      move startFile to destinationFolder
                                                      on error
      activate
                                                                display dialog "File “" & (name ofstartFile) & "” already exists in folder “" & theFolderName & "”. Do you want to replace it?"buttons {"Don't replace", "Replace"} default button 2 with icon 1
                                                                if button returned of result is "Stop"then
                                                                          if (count theLastFolder) is 0 thendelete theLastFolder
                                                                          return
                                                                else if button returned of result is"Replace" then
                                                                          set fileName to get name ofstartFile
                                                                          if exists file fileName indestinationFolder then ¬
                                                                                    try
      --next line moves existing file to the faketrash
      move file fileName of destinationFolder to fakeTrash
      move file startFile to destinationFolder
      --if it already exists in fake trash give it a new name then move that file to fake trash
                                                                                    on error errmess numbererrnum -- oops (should probably check for a specific error number)
                                                                                               log "Error " & errnum& " moving file: " &errmess
                                                                                               set newName to mygetUniqueName(fileName,fakeTrash)
                                                                                               set name of fileNameto "this is a unique name"-- or whatever
                                                                                               set name of fileNameto newName
      --Now move the renamed file to the fake trash
      move file fileName to fakeTrash
      --now move the startfile to destination folder
      move file startFile to destinationFolder
                                                                                    end try
                                                                else -- "Don't replace"
                                                                          if not (exists folder "Hal 9000:Users:matthew:Desktop:Rejected Folder Done") then
                                                                                    set theLastFolder toduplicate foldericonto desktop
                                                                          else
                                                                                    set theLastFolder to folder"Hal 9000:Users:matthew:Desktop:Rejected Folder Done"
                                                                          end if
                                                                          delay 0.5
      move startFile to theLastFolder with replacing
                                                                end if
                                                      end try
                                            end repeat
                                  end repeat
                        end if
              end repeat
              try
                        if (count theLastFolder) is 0 then delete theLastFolder
              end try
    end tell
    to getUniqueName(someFile, someFolder)
         check if someFile exists in someFolder, creating a new unique file name (if needed) by adding a suffix
              parameters -          someFile [mixed]: a source file path
                                  someFolder [mixed]: a folder to check
              returns [list]:          a unique file name and extension
              set {counter, suffixes, divider} to {0, "abcdefghijklmnopqrstuvwxyz", "_"}
              set someFile to someFile as text -- System Events will use both Finder and POSIX text
              tell application "System Events" to tell disk item someFile to set{theName, theExtension} to {name, name extension}
              if theExtension is not "" then set theExtension to "." & theExtension
              set theName to text 1 thru -((length of theExtension) + 1) of theName -- just the name part
              set newName to theName & theExtension
              tell application "System Events" to tell (get name of files of folder(someFolder as text))
                        repeat while it contains newName
                                  set counter to counter + 1 -- hopefully there aren't more than 26 duplicates (numbers are easier)
                                  set newName to theName & divider & (item counter ofsuffixes) & theExtension
                        end repeat
              end tell
              return newName
    end getUniqueName

    There are numerous errors in your script, and it's a large script so there might be more, but these are the standouts for me:
    At line 48 you:
                                                                          set fileName to get name of startFile
    which is fair enough - you then use this to see if the file already exists in the destinationFolder. However, if it does the logic about how to deal with that is flawed.
    At line 56 you catch the error:
                                                                                    on error errmess number errnum -- oops (should probably check for a specific error number)
                                                                                              log "Error " & errnum & " moving file: " & errmess
                                                                                              set newName to my getUniqueName(fileName, fakeTrash)
                                                                                              set name of fileName to "this is a unique name" -- or whatever
                                                                                              set name of fileName to newName
      --Now move the renamed file to the fake trash
      move file fileName to fakeTrash
      --now move the startfile to destination folder
      move file startFile to destinationFolder
                                                                                    end try
    so let's focus on that.
    56: catch the error
    57: log the error
    58: generate a new unique filename
    59: change the name of fileName to some other string
    Hang on, wait a minute.... we already ascertained that at line 48 you defined fileName as a string object that indicates the name of the file. This is just a string. It's no longer associated with the original file... it's just a list of characters. Consequently you cannot set the 'name' of a string, hence your script is doomed to fail.
    Instead, what I think you want to do is set the name of the startFile to the unique string. Files have filenames, and therefore you can set the name.
    You have a similar problem on line 64 where you try to 'move file filename to fakeTrash'. fileName is just a string of characters. It isn't enough to identify a file - let's say the file name is 'some.psd'. You're asking AppleScript to move file some.psd to the trash. The question is which some.psd? The one on the desktop? in your home directory? maybe on the root of the volume? or maybe it should search your drive to find any/all files with that name? nope. None of the above. You can't just reference a file by name without identifying where that file is. So you probably want to 'move file fileName of destinationFolder...'
    There may be other problems, but they're likely to be related - all issues with object classes (e.g. files vs. strings), or not being specific about which object you want.
    As I said before, though, I might be way off - you don't say where the error is triggered to make it easy to narrow down the problem. Usually AppleScript will highlight the line that triggered an error. Knowing what that line is would help a lot.

  • Export as Separate PDF Pages with Unique Names

    I have an InDesign document that has several pages. I want to export each page as a seperate PDF, but they have to have a unique name that I want to be able to specify.
    For example, I want to export page 1 as "calendar page 2014"
    Page 2 as "Diary page 2014" etc.
    I found some solutions, but they aren't quite what I need:
    Export as Seperate pages with image name
    This apple script takes the name of the first image on the document and uses that as the name.
    However, my document has no images.
    Exportools
    A paid tool that offers many options for exporting. However, the name has to be based on a pattern, which is no good for me.
    I'm hoping that there will be a script that can take the name from a non-printing area/layer. That way, I can just put the desired name on the page and it will export with that name each time.

    have you looked at the extention Autosplit PRO?  This may be what you are looking for.  (Although, I don't think this software is compatable with MAC...but if you find out otherwise, please advise!)
    good luck..

  • Create multiple instances of same class but with unique names

    Hi,
    I'm creating an IM application in Java.
    So far I can click on a user and create a chat session, using my chatWindow class. But this means I can only create one chatWindow class, called 'chat'. How can I get the application to dynamically make new instances of this class with unique names, for examples chatWindowUser1, chatWindowUser2.
    Below is some code utlising the Openfire Smack API but hopefully the principle is the clear.
        private void chatButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
            int selectedUserIndex = rosterList.getSelectedIndex();
            String selectedUser = rostAry[selectedUserIndex].getUser();
            System.out.println("Chat with: " + selectedUser);
            if (chatBox == null) {
                JFrame mainFrame = CommsTestApp.getApplication().getMainFrame();
                chatBox = new CommsTestChatBox(mainFrame,conn,selectedUser);
                chatBox.setLocationRelativeTo(mainFrame);
            CommsTestApp.getApplication().show(chatBox);
    }  

    yes, an array would work fine, just realize that by using an array, you're setting an upper bound on the number of windows you can have open.
    As for unique names, if you mean unique variable name, you don't need one. The array index serves to uniquely identify each instance. If you mean unique title for the window, set that however you want (username, index in array, randomly generated string, etc.). It's just a property of the window object.

  • Excel Template - Save with Unique Names

    Hi - I have a SharePoint 2010 document library with an Excel template as the template.  When a user creates a New Document (new Excel workbook from template), the name of the new file is "PSR1".  Someone else may have also created a
    new workbook, where the default name is PSR1.  How can you get Excel to name the file uniquely with each template?  I've set up fields to capture user name and date/hours/mins/sec and have it concatenated ina field for use as the name, but I can't
    get Excel to use it or figure out how to make SharePoint require unique file names.  Thank you.

    OOTB way there isn't any option to allow users to provide a specific file name, either you can set content approval for that document library or set an announcement / header asking users to only save file with that specific name series.
    Regards,
    Pratik Vyas | SharePoint Consultant |
    http://sharepointpratik.blogspot.com
    Posting is provided AS IS with no warranties, and confers no rights
    Please remember to click Mark As Answer if a post solves your problem or
    Vote As Helpful if it was useful.

  • PDF form with one submit button that prints form and sanves PDF with data with a unique file name

    We have a long medical form that patients can fill out at kiosks as they wait to see a doctor. We want one button so that the patient can print out the form with one click (and finish filling it out by hand if it's not finished already) and the same button click will save the form with a unique file name (using last name, first name, date, and/or email address so that the identity of the person who filled out the form will be readily apparent to anyone who wants to grab the user's responses later). Is Acrobat capable of doing something like this? LiveCycle Designer maybe? And if we continue with the PDF form and add a submit button, is there a way to program the button click to print and to save?
    Thank you in advance of any suggestions that might accomplish this task.

    I am not sure about the print, but it can probably be done -- possibly with a bit of JavaScript. As to the saving of the form, that is not reasonable at a kiosk. You would want the data submitted to a server (particularly with patient data), no e-mail or accessible drive. You can collect the data and put it in a database or import it to the form for printing yourself.

  • Identifying Multiple printers with unique name?

    I support an office staff of 40 users that share 15 Officejet 100 L411a printers. When users connect a printer by USB, the computer will create a new printer with the default name "HP Officejet 100 Mobile L411" printer if that printer hasn't connected to that computer before. If the printer has been connected before, a new printer is not created.
    Many users have multiple copies of printers all with the same printer name "HP Officejet 100 Mobile L411". The printer that is connected is highlighted; all other printers are grayed out.
    My users want to know which printers they've checked out before when they pick up a printer. The users can rename the printers manually but most don't want to do that. I can rename them for the users, but that's a lot of users and a lot of printers. Either way, the next time they get a printer they haven't used before they'll get the default name.
    I'd like to know if there is a way to set the printer's firmware to create a unique name when the printer is created by using the serial number or another designation I could enter.
    For example, I'd like to have "HP Officejet 100 #MY1555AAQQ" or "HP OfficeJet 100 Purple #12" show up as the printer name. Is there any way to do that?

    Our requirement is...
    Yep, had this requirement as well.
    All these various user name collisions and worse is different IDs for the same person can be solved relatively easily by IdM.
    But best practice is still to remove the collisions and use unique IDs. Same goes for deleting users (dont do it).
    Good luck.
    Cheers,
    Julius

  • Lightroom Faces: Two People with the Same Name

    I downloaded Lightroom CC last night and came up with the following question:
    I have an uncle and a cousin with the same name...can Lightroom create two different "people" or will I need to name them each differently? I'm guessing it's the latter but figured I'd pose the question in case there is an alternate solution.

    johnrellis schreef:
    You might have a keyword for each family grouping, e.g. "John Ellis Family" and "Steve Ellis Family", and then place the keywords for the members of each under those parents.  E.g. under "John Ellis Family" you'd have "John Ellis", "Mary Ellis", "Jane Ellis", etc.   And under "Steve Ellis Family", you might have "Steve Ellis", "Kathryn Ellis", and "John Ellis" (a different John Ellis).
    It's a good idea to work with hierarchies. But for the face option to work, you will have to have two unique names.
    I just did a quick test.
    I have some images of twins in my catalogue, Tom and Boris.
    Under them, I created a "name" Twin. Because of the hierarchy, I can apply Boris>Twin to one image, Tom>Twin to another and both of them to a third photo.
    So I drag a name box around them and type "Twin". The drop down (auto fill) lets me choose between two identical looking entries called "twin". No way of knowing which one to pick. And maybe you've noticed that the auto fill drop down list starts with entries you used recently. So no good remembering that the top "Twin" will always be "Boris" for example.
    The count of used keywords only goes up for one of them if I happen to use the same entry twice.
    The only way for this to work (as far as I can tell now) is to drag the appropriate "Twin" from the keywordlist onto the right face in the People view (O).
    I work with hierarchies, but I make sure I have unique names.
    Also, I don't use spaces in the names, but rather JohnEllis, SteveEllis, etc. That way, if I have a very long list with Ellis members and also a lot of people called John or Steve, it's much easier to narrow the search for a particular person (like in smart collections).
    Opening the properties for the keyword, I make sure that "include on export" is NOT on, so you won't see that strange looking name Number123JohnEllis in your exported image.
    I have "export containing keywords" and "export synonyms" (and now with LR CC of course "Person") checked. As a synonym, you can put "John, Ellis, John Ellis, Steve Ellis family" and all of these will export.
    Hope this makes sense.
    Like John suggests, if you already create the Ellis Family>Steve Ellis Family>John Ellis>John>Numer123JohnEllis then you don't have to enter the synonyms, as long as you have "export containing keywords" on all of them checked, as well as "include on export" (except for the Number123JohnEllis keyword which shouldn't have "include on export" checked).
    Working with hierarchies can really help you in your keywording. But it will take some time to set it up.

  • Custom fields with the same name in Project Online

    Today I discovered something interesting when creating custom fields in Project Online.
    I usually create a certain set of custom fields that are useful to have on both the project and the task level. An example of these is Reportable, which I use to determine which tasks to roll up into reports and also which projects overall to report on.
    So I created a project level custom field called Reportable. No problem.
    I then created a custom field on the task level called Reportable. And the computer said no!
    I then learned that although you could do this in Project Server 2013, you can't in Project Online. You can't have duplicate custom field names, even if they are of different types.
    This has led me to use a naming standard, such as Reportable Task and Reportable Project. But I really don't like that as codes are for computers, not us humans. So I hope this changes in the future, but for now you just need to think about how you approach
    the fields.
    Good luck!
    Ryan Darby
    National Manager PMO
    www.ipmo.com.au
    www.projectonline.com.au

    Hi Ryan,
    I would follow Ben on this..
    Just made a test on a Project 2013 instance on-premise and I cannot create a task ECF and a project ECF with the same name. The same test on a Online instance returns the same result: the ECF names must be unique whatever the entity is.
    Waiting for Ben's confirmation.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

Maybe you are looking for