How to count ONLY fields with a specific value

I modified the code below from the API reference to count combobox fields with a value of "MT" so I could total the number of a specific choice the form user input.
var count = 0;
for (var i=0; i<this.numFields; i++)
var fname = this.getNthFieldName(i);
if ( this.getField(fname).type == "combobox" && this.getField(fname).value == "MT" ) count++;
this.getField("mTurb").value = count.value;
Here's the problem: I tried to use a similar script, modified only slightly from this form, in another total field to tally a different choice made with comboboxes and the script continues to tally the first choice. An example of one of the modified versions of the script is below.
var gcount = 0;
for (var i=0; i<this.numFields; i++)
var gname = this.getNthFieldName(i);
if ( this.getField(gname).type == "combobox" && this.getField(gname).value == "MT" ) gcount++;
this.getField("gPack").value = gcount.value;
I suspect I'm just missing something painfully obvious to seasoned scripters, but I can't seem to figure it out and I need this script to be able to count the number of 9 different options in the comboboxes.

OK, you can use a script like the following as the custom calculate script for the text fields that perform the counts:
// Custom calculate script for text field
(function () {
    // Declare and initialize variables
    var fn, s = "MT", count = 0;
    // Loop through the combo boxes
    for (var i = 1; i < 25; i++) {
        // Determine the current field name
        fn = "M" + util.printf("%02d", i));
        // See if the field value matches
        if (getField(fn).valueAsString === s) count++
    // Set this field value to the count
    event.value = count;
Change the value of the "s" variable to match the item that you want to count. The first and last lines prevent the unnecessary creatio of global variables, which is good. It also makes it easy to transfer to a more general document-level routine, which would be event better, something like:
// Custom calculate script for text field
function getCBCount(s) {
    var fn, count = 0;
    // Loop through the combo boxes
    for (var i = 1; i < 25; i++) {
        // Determine the current field name
        fn = "M" + util.printf("%02d", i));
        // See if the field value matches
        if (getField(fn).valueAsString === s) count++
    // Set this field value to the count
    event.value = count;
You would then call this function from the individual text boxes with the following custom calculate script:
getCBCount("MT");
and replace "MT" with the vlaue you want to count.

Similar Messages

  • How to count only cells with content?

    I'd like to get a count of all cells in a column that have content. Any ideas how that can be done?

    "The COUNTA function returns the number of its arguments that are not empty."
    In Numbers, there's a handy Function Browser, which makes it easy to discover and learn about the "function capabilities" of the application.  In fact, the first sentence I provided above was actually taken verbatim from the Function Browser, hence the quotation marks.
    You can find the Function Browser just above the Format Bar, to the left of the Formula List icon.
    I hope information this helps you.

  • How To BLank A Field With A Numeric Value

    I am trying to write a formula as follows:
    IF {CRD1.U_PriceOnPick} = "N" THEN
    ELSE
    {ODLN.DiscPrcnt}
    My problem is I need for the field not to display if = "N" else I will print the numeric field of {ODLN.DiscPrcnt} . I am not sure how to code a formula that will meet my objective. When I try to save the formula, I receive an error of , "A String Is Expected Here". Any help would be appreciated it.
    Thanks Jim Dyer

    Cardinal rule of CR, the result of both the IF and ELSE parts must be of the same data type.
    Try changing your formula to:
    IF {CRD1.U_PriceOnPick} = "N" THEN
    ELSE
    totext({ODLN.DiscPrcnt});

  • How to create a field with  1200 chars length

    Hi,
    Will anybody let me know how to create a field with length 1200 in a table.
    Regards,
    Madhavi

    Hi Madhvi,
    Other thing what you can do is
    1. First create a Table type.
         Goto SE11-> Dataelements ->Table type
         There on the next screen select Predefine radio button & there provide data type & size.
    2. Create a structure having a field typa of Table type created before. say that field is quant.
    Now in your program refer that structure to create an internal table & work area.
    Now if u append ur text to the field quant.
    try creating line type of size more that 255 if it works then fine other wise reduce it.
    Note:: This will be a deep structure.
    so first append value to the field quant,  the at the end of first record append valu to ur internal table.
    thanks
    Satyam

  • How to create a String with a specific size?

    how to create a String with a specific size?
    For example I want to create different Strings with the size of 100 , 1000 or 63k byte?

    String are immutable so just initialize it with the number of characters you want.
    You might want to look at java.lang.StringBuffer and see if that's what you want.

  • How to map Idoc fields with external file

    Hi All,
    How to map Idoc fields with external file.
    I want to check the settings where Idoc fields are mapped with external file.
    Thanks in advance.
    Regards,
    Govind.

    If you have configured a fileport where on trigger of IDOC you are creating the file, you can look at the message type documentation and get the offset values for each field in each segment

  • Form field with comma delimited value list to cfc

    I have a form that passes a field to an action page with a
    comma delimited value.
    For instance the field name is: Program_ID
    value for program_ID is: 31, 32
    I am able to treat this variable as a list and check its
    length, and loop over the list prior to passing it to a cfc using
    the attached code:
    When I try and pass the variable as a string to a cfc and
    invoke a query, cf no longer recognizes my var as a list.
    Therefore the code attached does not function...
    Is there a specific var type that will pass through as a list
    and allow me to run the code block attached?
    thanks
    Craig

    Ok answered my own question.. Here is the answer for those
    who are interested...
    initialize var for cfc in cfinvoke statement
    <cfinvokeargument name="Program_ID"
    value="#Form.Program_ID#">
    pass argument to cfc as a string
    <cfargument name="Program_ID" type="string"
    required="true">
    use listqualify to parse list in cfc and set new var
    <cfset selectedProgramID =
    ListQualify(Program_ID,"'",",","CHAR")>
    use the new var in the following statement in sql code:
    ((Program_ID) IN (#PreserveSingleQuotes(selectedProgramID)#))
    The following code handles a form field with a single value
    or a comma delimited value.

  • How to know if implementation with a filter value exist for a BAdI in code?

    Hi all,
    Scenario:
    I created a BAdI. There will be a button on the UI to call its implementation(s); while if there is no implementation with specified filter value, this button needs to be hidden. Thus I need to know if the implementation exist before calling it.
    Question:
    In the ABAP code, how to get whether implementation with specified filter value exists for a BAdI?
    If it's possible, please help provide code.
    Thanks and regards,
    Said

    Problem solved:
    data: r_badi type ref to YOUR_BADI,
              badi_impl_num type i.
      get badi r_badi
        filters
          flt_name = fit_val.
      badi_impl_num = cl_badi_query=>number_of_implementations( badi = r_badi ).
      if badi_impl_num > 0.
        "there are badi implementation(s)
      endif.

  • XML FORM  -  How to save read-only controls with a default value

    Hello everybody,
    I have a 3 xml forms, each one to create one type of news. I need to use 3 because each of this forms has their own controls. But the control which indicates the type of news (asociated with a KM Predefined Property) must be common in the 3 forms, in order to use it on searches.
    The question is, how can I include in this forms a control:
      - Visible for the user
      - With a default value defined in the control properties (each form has a different value, corresponding with the type of news)
      - Read-only mode
      - The value showed in the control must be saved in the associated KM Predefined Property when the user clicks the Save button. 
    Anyone knows how to do this?
    What control can I use?
    I was thinking of trying with text boxes, but I don't find the way to make them unwritable (Read only mode).
    It is posible using labels?
    Thanks.
    Kind regards

    Hello Jose,
    I know you responded with a question... I see it in the email, but I don't see it here!  Very odd... but in response:
    The first thing I do when I open the Edit.xsl file is do a 'find' for the name of the text field that I want to be read-only (in my test case, it's 'location').  Repeat the find until you see something like:
    [code]<!--
    field location
    -->[/code]
    Below there is where I put the new code.  Mine looks like this:
    [code]- <xsl:choose>
    - <xsl:when test="location='' and ($editmode='create')">
    - <xsl:choose>
    - <xsl:when test="./xf:ValidationError/@tagname='location'">
    - <input name="location" size="30" type="text" class="urEdfiTxtEnbl" id="field_1157467268006">
    - <xsl:attribute name="tabindex">
    - <xsl:choose>
      <xsl:when test="$accessibilitymode='true'">21</xsl:when>
      <xsl:otherwise>3792</xsl:otherwise>
      </xsl:choose>
      </xsl:attribute>
    - <xsl:attribute name="value">
      <xsl:value-of select="''" />
      </xsl:attribute>
    - <xsl:attribute name="readonly">true</xsl:attribute>
      </input>
      </xsl:when>
    - <xsl:otherwise>
    - <input name="location" size="30" type="text" tabindex="3792" class="urEdfTxtEnbl" id="field_1157467268006">
    - <xsl:attribute name="value">
      <xsl:value-of select="''" />
      </xsl:attribute>
    - <xsl:attribute name="readonly">true</xsl:attribute>
      </input>
      </xsl:otherwise>
      </xsl:choose>[/code]
    I put the <xsl:attribute name="readonly"> in both places (when test, and when not test).  I'm not entirely sure if that's necessary, but that worked for me.
    Hope this helps,
    Fallon

  • How to remove a dispatcher with a specific index (conf_indx)

    Hi,
    A few details:
    We are on 11.2.0.3 linux 64bit.
    We use both dedicated and shared connection.
    We have many environments (an environment consists of many schemas) in a single DB.
    For each environment we create at least one service (we know # of services is limited to ~150 in 11.2) - in example for environment with suffix LAB1 we create a service called DB_LAB1
    in example:
    exec dbms_service.create_service('DB_LAB1','DB_LAB1');
    exec dbms_service.start_service('DB_LAB1');
    For clients to be able to connect to the service_name using shared mode - we also create a dispatcher per environment - serving that specific service -
    in example:
    alter system set dispatchers='(index=30)(protocol=tcp)(service=DB_LAB1)(dispatchers=1)'
    I have a few environments which I would like to remove - including their services and dispatchers.
    removing the services is easy using dbms_service - however I did not find a way to remove/delete a dispatcher with a specific index.
    Say I have conf_indx 1..50 used and I would like to remove conf_indx=30 (the one which I created above) - how can I do that?
    Stopping the dispatcher process (Dxxx) does not remove the row from v$dispatcher_config - it only shows that the number of dispatchers for that row is 0.
    Bottom line - how to remove a specific dispatcher with a specific dispatcher-index - without affecting all the other dispatchers which I would like to preserve?
    Thanks.
    Mor

    Ok, but how does one remove some of the applications that are appear in the context menu for a given file type? Is there an asc file which can be edited?
    For example, in my system a PDF can be opened with over 10 applications. I would like to see just the three ones I use: Acrobat, Skim and Preview.
    Thanks in advance.

  • How to make a field with inserted field's values editable?

    Experts, please help!!
    I have a form with 2 views.
    View 1 has a field named "Name". View 2 has a field named "Notice"
    On view 2, I set up the default value for "Notice" as  Concat ( Name, " has enrolled this year")
    The form data will be submitted to sharepoint library.
    I tried to edit "Notice" field on view 2 and submitted it to the library, but when I opened it I didn't see the changes I made.
    Is there any way to make the field "notice" Editable and being able to save the chaanges on View 2?
    I know if I set up the value for notice just by text string without inserted value, it will capture my changes but that is not what I want.
    Please help, thanks.
    yuhong xiao

    Hi,
    According to your description, you might want that "Notice" field has a default value when form is created and users can be able to change the value of that
    field.
    As a workaround, you can add an action rule in “Name” field via InfoPath to fill the default value in “Notice” field only when “Name” field is not blank and “Notice”
    field is blank.
    Settings of the rule are as below, you can modify it based on your need:
    Here is a link about how to add an action rule in InfoPath form, you can use it as a reference:
    https://support.office.microsoft.com/en-us/article/Add-rules-for-performing-other-actions-5322d726-b787-4e5f-8d37-ba6db68b451d?CorrelationId=8a64c12f-aa60-4d90-b1f9-a44fcc4e74b5&ui=en-US&rs=en-US&ad=US
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to Run std program with a specific variant for specific user?

    Hi guys
    We have a std program which will be run by different users in the company. Now the requirement is to make sure that each user runs the report with a specific varaint. Can we control this if yes how?
    one options we thought about was to create a transaction in SE93 and define the program to run with a predefined varaint and assign the new custom tcode to the user profile. But we have many different users and we will end up with creating many transactions which we would like to avoid. Is there any other option to control the std program such that each user can run the program only with a pre-defined varaint and the one which only the user is suppoed to run. thanks in advance.

    We have a std program which will be run by different users in the company. Now the requirement is to make sure that each user runs the report with a specific varaint. Can we control this if yes how
    you can do this..
    You can create a Custom table
    userid     keyfield
    program  keyfield
    variant    keyfield
    programdesc
    Make the table Maintaintable(usnig table maintenance )
    Now create another Program
    It takes input of the Program name( using selection screen)
    LOGIC
    in side that place a logic ,
    Based on the user name  and program name Get the variant name from above table
    Now Submit the program with the variant you have selected above.
    Use Variant Addition when you use SUBMIT
    So now program executed based on user variant.
    Now you create a Transaction for this program.
    When use Runs the Transaction , user needs to input the Program name which he wants to execute.
    and Output will be shown based on the variants
    Regards
    Vijay Babu Dudla

  • Can no longer select text in email template or read only field with mouse using IE or Firefox?

    Hi Guys,
    I can no longer select text in email template or read only field using my mouse in IE or Firefox anymore. We are using CRM 2011 rollup 18 applied with IE 11 and the latest version of Firefox. We only applied roll up 18 in Feb when this issue began.
    Thanks
    Dave
    David Kelly

    When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.
    (1) Bypass Firefox's Cache
    Use Ctrl+Shift+r to reload the page fresh from the server.
    (You also can clear Firefox's cache completely using:
    orange Firefox button ''or'' Tools menu > Options > Advanced
    On the Network mini-tab > Cached Web Content : "Clear Now")
    (2) Remove the site's cookies (save any pending work first) using either of these. While viewing a page on the site:
    * right-click and choose View Page Info > Security > "View Cookies"
    * Alt+t (open the classic Tools menu) > Page Info > Security > "View Cookies"
    Then try reloading the page. Does that help?
    These features rely on JavaScript, and it sounds as though you have scripting enabled if you get (the wrong) color changes. Some add-ons might alter the way scripts operate, so a standard diagnostic to bypass interference by extensions (and some custom settings) is to try Firefox's Safe Mode.
    First, I recommend backing up your Firefox settings in case something goes wrong. See [[Backing up your information]]. (You can copy your entire Firefox profile folder somewhere outside of the Mozilla folder.)
    Next, restart Firefox in Firefox's Safe Mode ([[Safe Mode]]) using
    Help > Restart with Add-ons Disabled
    In the dialog, click "Start in Safe Mode."
    If those features work correctly, this points to one of your extensions or custom settings as the problem.
    To also disable plugins, you can use this page:
    orange Firefox button ''or'' classic Tools menu > Add-ons > Plugins category
    Any change?

  • Union two tables with diffrent count of fields with null and float value

    Hello,
    i want to union two tables, first one with 3 fields and second one with 4 fields (diffrent count of fields).
    I can add null value at end of first select but it does not work with float values in second table. Value form second table is convert to integer.
    For example:
    select null v1 from sessions
    union
    select 0.05 v1 from sessions
    result is set of null and 0 value.
    As workaround i can type:
    select null+0.0 v1 from sessions
    union
    select 0.05 v1 from sessions
    or simple change select's order.
    Is any better/proper way to do this? Can I somehow set float field type in first select?
    Best regards,
    Lukasz.
    WIN XP, MAXDB 7.6.03

    Hi Lukasz,
    in a UNION statement the first statement defines the structure (number, names and types of fields) of the resultset.
    Therefore you have to define a FLOAT field in the first SELECT statement in order to avoid conversion to VARCHAR.
    Be aware that NULL and 0.0 are not the same thus NULL+0.0 does not equal NULL.
    In fact NULL cannot equal to any number or character value at all.
    BTW: you may want to use UNION ALL to avoid the search and removal of duplicates - looks like your datasets won't contain duplicates anyhow...
    Regards,
    Lars

  • How to fill a field with after changing another field in a multi form?

    Hi,
    I have multi occurence form in which multiple record are showeds and/or added.
    One field is a dropdown field, after filling this field (selecting a value in the dropdown), another field needs to filled with the selected value.
    My problem is that only the first occurence is filled with the value of the selected dropdown, even when filling the dropdown field in one of the other occurences.
    I tried point to the other occurences but this was not succesfull
    See script
    So when a sparepart is selected from the dropdown sparepart, the field defectpart must be filled the selected sparepart, when I have multi forms (occurences) only the first occurence defect part gets filled with the selected parts, even when a sparepart from another occurence is selected.
    data.p1.spare_parts.spare_parts::change: - (JavaScript, client) -
    p1.spare_parts.DefectPart.rawValue =  xfa.event.newText;
    Can anyone help to solve this problem
    Thanks
    Christophe Van Mechelen

    hi,
    Your code is right, i dont know why its not working,
    try this,
    dropdown field in change event,
    var c = xfa.host.newtext
    textfield1.rawValue = c;
    (or)
    textfield1.rawValue = xfa.event.newText;
    by
    Parthi

Maybe you are looking for

  • 20.1-Inch External Monitor

    I'm looking at buying a MacBook Pro later this summer, but I'm interested in buying a new 20.1-Inch monitor in the next week and I want to know which one is better. I will use it for gaming and video playback and once I get my MacBook Pro the monitor

  • Generated Webservice proxy: Maximimum size of byte array

    Hi, We have generated a webservice proxy with JDeveloper (version 10.1.3.4.0) from a WSDL supplied by a .Net webservice. One of the Webservice returns a byte array. We are facing a problem when the size of the returned byte array exceeds the limit of

  • Handling queue through UDF

    I have input as A1 A2 A2 A3 context change A1 A1 context change A1 A5 I have to pick unique values from all context keeping them in same format... Output Required A1 A2 A3 context change A1 context change A1 A5 How it can be achieved through message

  • Macbook Pro camera slow/laggy?

    I have a relatively new Macbook Pro Model A1398 Mid 2014 and the built in camera is very slow and lags. For example, if I wave my hand over the camera, I could see the slow movement of my hand and even after I finish waving, on the screen, I would st

  • Safari 2.0.1 says "you need 10.4" and I have 10.4.8

    I've just tried to install Safari 2.0.1 (currently using Safari 1.3.2) on my PowerMac (dual 1.8 G4s) and I keep getting a message that says, "You cannot install Safari Update 2.0.1 on this volume. This software requires Mac OS X 10.4.2." I'm happily