Single or multiple check box values displayed in a textbox

Hi Experts!
I'm using the following script to display the values of check boxes in a text field.  I would like the word "and" to separate the values if two check boxes are selected. If more than two boxes are selected I want the values to be separated by a comma and then the last value be separated by "and".  Example of two check boxes selected:  A and B.  Example of two or more: A, B, C, and D.  Can this be done?
form1.page1.page1SF.programs::calculate - (JavaScript, client)
//displays the values of check boxes named programCB
var aChkBx = [];
var vChecks = programCB.all;
for (var a=0; a<vChecks.length;a++){
if(!vChecks.item(a).isNull) {
aChkBx.push(vChecks.item(a).rawValue);
this.rawValue = aChkBx.join(", ");

So, the way I see it, you actually have four scenarios. Nothing is checked, one item is checked, two items are checked, and three or more items are checked.
Here's how I did it.
I have four checkboxes all with the same name, cb. (You could have many more, and it wouldn't matter as long as they're all named the same thing.) I'm presuming that you will use the captions from the checkboxes as the text you want to enter. I called my text area where I enter the information tfSentence. (It's not a text field, it's just called "Text" in the Object Library.)
//we need to count how many boxes are checked
var checked = 0;
for (i=0; i<=cb.length; i++){
  if (xfa.resolveNode("cb["+i+"]").rawValue == 1) checked ++;
//create a string variable to store our sentence
var str = "";
//look at the checked variable and choose our case from that
switch(checked){
  case 0:
    //you may want to do more than just type out a sentence here, like a message box
    tfSentence.rawValue = "Nothing was selected";
    break;
  case 1:
    //you can set text that will appear before your list of items here
    //str = "preliminary text";
    for (i=0; i<=cb.length; i++){
      if (xfa.resolveNode("cb["+i+"]").rawValue == 1) str += xfa.resolveNode("cb["+i+"].caption.value.#text").value;
    //you can set text to appear after your list of items here
    //str += "ending text";
    tfSentence.rawValue = str;
    break;
  case 2:
    //str = "preliminary text";
    for (i=0; i<=cb.length; i++){
      if (xfa.resolveNode("cb["+i+"]").rawValue == 1){
        if (checked == 1) str += " and " + xfa.resolveNode("cb["+i+"].caption.value.#text").value;
        else str += xfa.resolveNode("cb[+i+"].caption.value.#text").value;
        checked--;
    //str+= "ending text";
    tfSentence.rawValue = str;
    break;
  default:
    //str = "preliminary text";
    for (i=0; i<=cb.length; i++){
      if (xfa.resolveNode("cb["+i+"]").rawValue == 1){
        if (checked == 1) str += "and " + xfa.resolveNode("cb["+i+"].caption.value.#text").value;
        else str += xfa.resolveNode("cb["+i+"].caption.value.#text").value + ", ";
        checked--;
    //str += "ending text";
    tfSentence.rawValue = str;
    break

Similar Messages

  • Single or multiple check box values displayed in a text field

    My apologies, this may be a duplicate discussion.
    I'm using the following script to display the values of check boxes in a text field.  I would like the word "and" to separate the values if two check boxes are selected. If more than two boxes are selected I want the values to be separated by a comma and then the last value be separated by "and".  Example of two check boxes selected:  A and B.  Example of two or more: A, B, C, and D.  Can this be done?
    form1.page1.page1SF.programs::calculate - (JavaScript, client)
    //displays the values of check boxes named programCB
    var aChkBx = [];
    var vChecks = programCB.all;
    for (var a=0; a<vChecks.length;a++){
    if(!vChecks.item(a).isNull) {
    aChkBx.push(vChecks.item(a).rawValue);
    this.rawValue = aChkBx.join(", ");

    My apologies, this may be a duplicate discussion.
    I'm using the following script to display the values of check boxes in a text field.  I would like the word "and" to separate the values if two check boxes are selected. If more than two boxes are selected I want the values to be separated by a comma and then the last value be separated by "and".  Example of two check boxes selected:  A and B.  Example of two or more: A, B, C, and D.  Can this be done?
    form1.page1.page1SF.programs::calculate - (JavaScript, client)
    //displays the values of check boxes named programCB
    var aChkBx = [];
    var vChecks = programCB.all;
    for (var a=0; a<vChecks.length;a++){
    if(!vChecks.item(a).isNull) {
    aChkBx.push(vChecks.item(a).rawValue);
    this.rawValue = aChkBx.join(", ");

  • Accessing check box values in to WF

    Hi guys,
    i am looping through a list to create simple table with some check boxes ( <FieldLoop for='loopvar' in='variables.apps[*]'> ). i have specified checkbox field name - as "loopvar"
    <Field name='loopvar'>
    <Display class='Checkbox'>
    <Property name='label'>
    <ref>loopvar</ref>
    </Property>
    </Display>
    </Field>
    how shud i pull / get the list of chek boxes selected on the userform in to WF? will the form return a list? and how shud be the name field syntax shud i use a ":varibales."? im confused. please guide me with the best practice to declare and access check box values
    Edited by: tea_or_kapi on Nov 20, 2009 10:44 PM

    Hi Raju,
    Try this.  Create another dataprovider within your web template?  This new dataprovider refers to a similar query, but this query definition should restrict values CG1, CG2, CG3 and CG4.  Assign this dataprovider to your checkbox.  Then make sure the properties of the checkbox affect all other dataproviders.
    Also, if this list is static, you could create an HTML checkbox object coding the options (cg1, cg2, cg3, and cg4) programmatically.  Then add javascript code to produce the proper filtering based on the users' selections.
    Let me know what happens.
    Larry

  • Multiple check boxes in an update form

    I have a database of the membership of a club. One field in the database is input by checking multiple check boxes. When the insert member record is submitted and multiple check boxes are selected, the information becomes an array of text separated by commas. When the user goes back to the update form, the check boxes are not showing checked in the appropriate fields. Please go to my test site where you will be able to see the code that I have created so far: http://www.usreboot.com/phphelp.php. You will need a user name and password to look at the update record page. Here you go: user name: wyane, password: wayne. I have submitted this request in the past and have not found success so far. Thanks for your help, Wayne Rowlands

    Thanks for getting back with me. I do have two tables. One table is the "members" table where all the information for the members is stored. One of the columns is "currentClubPositions". The database has another table which is "positions" which has the list for the positions that a member of the club could serve on. Members of the club may be serving on a number of positions at once, therefore the check boxes. Also, the club is adding and deleting positions over time, so I wanted an easy way to add them and delete them without having to go into phpmyadmin to do this. I have created a form that updates the "positions" table. The check boxes that show up in the insert member record and update member record are dynamic so that when the table "positions" changes, the forms change dynamically as do the queries to sort the database change dynamicaly. When the check boxes are entered, I use the implode function to make the values an array of text separated by commas and that value is inserted in one field of the members table named "currentClubPosition". I am all ears to hear a better way. Take a look at the web pages (see the original post) that I have created and you will see how all this ties together. Thanks, Wayne Rowlands

  • How can multiple check boxes be added at one time to a form?

    How can multiple check boxes be added at one time to a form?

    Thanks for your response, but copying and pasting creates a link. If the user places a check mark in one of the boxes, all the rest of the boxes will have a check mark also. I will research this some more.
    Carol Deatherage
    Receptionist
    Novar/Honeywell
    1000 SE 14th Street
    Bentonville, AR 72712
    Office:  (800) 341-7795
    Fax: (479) 271-0657
    [email protected]<mailto:[email protected]>
    Your feedback is important to us! Please take a moment to rate this response.
    Click Here to Access the Survey<https://www.surveymonkey.com/s/NovarSurvey>!
    This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately.
    Novar Confidential ***

  • How to insert check box value in table?

    Hi all
    kindly help me how to insert check box value in database. what code i have to use as i am new in programing.
    thanx in advance

    Hi,
    There is no "Check box" in a table, a check box is a GUI (Graphical user interface) item.
    What you want is to store a boolean value in a table. For that you can use the varchar2(1) datatype and store Y or N. (or anything else)
    (you cannot define boolean as a datatype for a column).
    If you're using a front-end application like apex then it might be useful for you to read the documentation about chekc boxes :
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/check_box.htm#CHDDFBFH
    (for the rest if it's Oracle Forms then everything is already said).
    Edited by: user11268895 on Aug 17, 2010 10:44 AM

  • Multiple check boxes in an update form using php

    I have a database of the membership of a club. One field in the database is input by checking multiple check boxes. When the insert member record is submitted and multiple check boxes are selected, the information becomes an array of text separated by commas. When the user goes back to the update form, the check boxes are not showing checked in the appropriate fields. Please go to my test site where you will be able to see the code that I have created so far: http://www.usreboot.com/phphelp.php. You will find the php code for the update form in a pdf file located there. You will need a user name and password to look at the update record page. Here you go: user name: wyane, password: wayne. I have submitted this request in the past and have not found success so far. Thanks for your help, Wayne Rowlands

    I am so close. If a member has only one check box checked. I get the check box checked in the update form. Here is the updated code:
    If the member has a number of check boxes checked, none of the check boxes are checked. I am so close. Maybe you can figure out what I am missing.  Thanks, Wayne

  • Update order user status based on a custom check box value in web ui

    Hi Experts,
    I have a requirement to Update the  user status based on a custom check box value in web ui.
    This is needed at the followup for a SR, the component is BT116H_SRVO, Details View.
    I created a value node with 4 checkboxes, based on the check box value, the corresponding user status
    need to be updated.
    How can I reach to the order save functionality of SAP in EH_ONSAVE method, so that syatem can capture my check box value, along with other screen fields, and append the status parameter in Order maintain?
    or do I have to call order maintain in even handler for checkbox, which will affect performance .....
    Pls help.
    Regards,
    Lakshmi

    Hi,
    In your event handler you can use bol entity corresponding to status BTStatusH and change the user status.
    Best regards,
    Caíque Escaler

  • Fetching sub-screen check box value in module pool

    Hi,
    i hav a req in which i craeted a sub-screen in a standard sap screen QA11 using screen -exit.
    This sub-screen has two check box's for 2 approvals.I hav craeted as screen with this 2 check box and made that as a sub-screen to main screen.
    I hav few validations to be performed on these 2 check-boxes.
    1.Enabling and disabling of resp check-box based on some condition.This is happening as i hav written some logic in PBO of the screen.
    2.Validations hav to be performed on the check-box like if user clicks a check-box that value has to be captured and stored in a Z custom table.My main issue comes here.i hav written some code in PAI,but when i put a break-point,that code is not at all getting triggered.
    Kindly,let me know how can i get the check-box value from the sub-screen which is craeted in the standard screen of QA11 using screen-exit.
    Thanks in advance

    Hi,
    May be your code is written in PAI of some other screen.
    check SY-DYNNR and also use this where you are checking chekbox value.
    make sure your code is written in PAI of same subscreen
    Thanks
    Raghav M.

  • FRM-40501 Error When Attempting To Change Check Box Value

    I am getting a FRM-40501 error when attempting to update/change a check box value. There are a few factors in my form setup that could be the problem, I will list them below:
    My initial problem was that my INSERT statement would not trigger to fire (based on an IF statement) when my check box value was not initially set to the value of 'Y', even though the initial value was set to 'Y' in the property palette (value when checked was set to 'Y' and value when unchecked was set to 'N'). So, to remedy this I placed a specific literal select of 'Y' and aliased it back to the name of my check box name in the data block query, like: SELECT 'Y' CB_SELECT_SCHOOL FROM user_schools. Then I changed the check box to a database item (value to Yes when it was No before my "SQL select cheat" in the data block query). This made the initial value 'Y' and satisfied my IF statement before my INSERT statement in my trigger. However, now I can not update the check box item.
    Does anyone know a better way to satisfy the initial value of my check box to 'Y', even though in the initial value parameter for my checkbox is set to 'Y' and forms is not really setting the initial value (when the check box is not set to a database item)?
    Thanks in advance.
    Kyle

    I have fixed my issue.
    I have reverted the check box to not be a database item, removed the "SQL cheat" of selecting 'Y' aliasing my checkbox name in the datablock SQL, and changed the initial value of 'N' in the check box property palette. This will force a change by the user making the check box value of 'Y', satifying my insert when-button-pressed trigger to fire and update the selected row.

  • LOV with auto suggest and multiple check boxes

    Is it possible to implement LOV with auto suggest and multiple check boxes using ADF faces components?. Any alternative implementation/pointers are appreciated.
    Regards,
    Surya

    Hi,
    build it yourself as a task flow opened in a popup. see: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/69-custom-lov-with-btf-276178.pdf
    Frank

  • How to use Multiple Check Box control  to make a list of items in check box

    I have a use case where i have to save update list of items required, and i want to implement it through viewobject and use Multiple check box control, how do i go about it? Code snippet will be helpful........
    Edited by: jDev_08 on Nov 17, 2012 8:31 PM

    Hi,
    Always mention your JDev version.
    Check out the ADF Faces Demo : http://jdevadf.oracle.com/adf-richclient-demo/faces/components/index.jspx#%2Fcomponents%2FselectManyCheckbox.jspx (Hint : Code snippet is available in there itself).
    -Arun

  • How to Save the multiple selection check box values into the database

    i have the multiple selection check box implemented in UI through drop down list,i can choose the desired values from the drop down through checkbox, but i m unable to store these values and commit the values into the database all at a time.

    You can access the values using listbinding and can then store them as a string by using a delimiter.

  • Collecting values from multiple check boxes with same name

    Hi,
    I have a jsp-page with one form with several check boxes sharing the same
    name (but with different values).
    Can I collect the values in an array/list or something?
    /jsp-beginner and google ain't my friend in this case

    this answer not good enough for you?

  • Passing check box values to WHERE clause

    Hi,
    I have created a Data block - 'CONTACTS' (Database data block)
    and has database item - 'Code', 'Descr'
    The number of records displayed is set to 5.
    Value When checked - 'Y'
    Value When Unchecked - 'N'
    Check box mapping of other values - 'unchecked'
    I am writing the code inside 'WHEN BUTTON PRESSED'. My main objective is to return the count of records based
    based on several conditions and one among them is CODE which is can be single or multiple based on the check box checked.
    The requirement is when i check one or multiple checkboxes, i should pass the 'Code' item values to the WHERE clause.
    Right now whenver i am trying to do so, only the current record value is copied to the WHERE clause.
    I have tried using basic loop but things havnt worked.
    Logic tried with basic LOOP
    BEGIN
    GO_BLOCK('CONTACT');
    IF :contact.cb = 'Y' THEN
    LOOP
    IF p_where is null then
    p_where := :contact.code;
    else
    p_where := p_where ||','||:contact.code;
    end if;
    exit when :system.last_record = 'TRUE';
    next_record;
    END LOOP;
    end if;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;
    And Even if i write the LOOP before the first IF, it return me the current record value and move to the last record.
    please guide me where am i wrong.
    Regards.
    Anoop.

    Try something like this:
    FIRST_RECORD;
    LOOP
      IF :contact.cb = 'Y' THEN
        IF p_where is null then
           p_where := :contact.code;
         else
           p_where := p_where ||','||:contact.code;
         end if;
       END IF;
      exit when :system.last_record = 'TRUE';
      next_record;
    END LOOP;
    -- END LOOP;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;

Maybe you are looking for

  • Difference between customizing request and workbench request?

    Hi , What is the difference between customizing request and workbench request? please reply.........

  • Windows 8.0 error 0xc0000185+ \WINDOWS\System32\drivers\mountmgr.sys

    So basicly what hapenned I was skypeing with some friends and suddenly my skype froze as it happened very often i pressed the CTRL+ALT+Del button to end skype But suddenly a message popped up in the left bottom corner of my screen it says windows is

  • AR aging report--from transaction date

    Hi Presently the 7/4 bucket aging report shows current and invoices no of days past due i.e. 31 days due past due date. Is there a report or any way by which this aging report can be generated to show aging from transaction date. Thanks Ninad

  • HD QT Pixlet won't playback well on Intel based systems?

    Hi all, I've been using Pixlet for a few years with no troubles on G5 computers at HD resolutions (1920x1080). I recently tried playback on our new Mac Pro and the playback is horrible. Is there something which prevents Intel based Macs from using Pi

  • Fastest type of data repository vi

    I have inherited a large LV application that in some instances runs VERY slowly. This is almost exclusively due to data transfers either between the application and the database or between some vis accessing data in repository vis. The first time dat