Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 676887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:58:42+00:00 2026-05-14T00:58:42+00:00

if i click on any checkbox all previous checkboxes must get checked my logic

  • 0

if i click on any checkbox all previous checkboxes must get checked
“my logic works”
if i uncheck a checkbox then all checkboxes after it must get unchecked
“how to do that”
MyLogic works for storm but not for other models
what to do

//well what i want to do is i have  5 checkboxes
class myscreen
{
 chk_service = new CheckboxField[5];                      
 chk_service[0]= new CheckboxField("1",true)
 chk_service[1]= new CheckboxField("2",false)
 chk_service[2]= new CheckboxField("3",false)
 chk_service[3]= new CheckboxField("4",false)
 chk_service[4]= new CheckboxField("5",false)

 CheckboxFieldChangeListener obj = 
    new CheckboxFieldChangeListener(chk_service);
    chk_service[0].setChangeListener(obj);
    chk_service[1].setChangeListener(obj);
    chk_service[2].setChangeListener(obj);
    chk_service[3].setChangeListener(obj);
    chk_service[4].setChangeListener(obj);


  hm4 = new HorizontalFieldManager();
  hm4.add(chk_service[0]);
  hm4.add(chk_service[1]);
  hm4.add(chk_service[2]);
  hm4.add(chk_service[3]);
  hm4.add(chk_service[4]);

add(hm4);
}


    public CheckboxFieldChangeListener (CheckboxField[] arrFields)
    {
        m_arrFields = arrFields;

    }

    public void fieldChanged(Field field, int context)
    {
        if(true == ((CheckboxField) field).getChecked())
        {
            for(int i = 0; i < m_arrFields.length; i++)
            {
                if(m_arrFields[i]==field)
                {
                    //a[j]=i;
                    j++;
                    break;
                }
                else
                {
                CheckboxField oField = m_arrFields[i];
                oField.setChecked(true);
                }
            }           
        }
        a[k] = j;
        if(false == ((CheckboxField) field).getChecked())
        {
            for(int i =field.getIndex(); i < m_arrFields.length; i++)
            {
                if(m_arrFields[i]==field)
                {
                    //a[j]=i;
                    j++;
                    break;
                }
                else
                {
                CheckboxField oField = m_arrFields[i];
                oField.setChecked(false);
                }
            }           
        }


    }  

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:58:43+00:00Added an answer on May 14, 2026 at 12:58 am

    try this code, work on tour, storm, bold

    alt text http://img78.imageshack.us/img78/70/cbbold.jpg

    class MyScreen extends MainScreen {
        int mCheckBoxesCount = 5;
        Vector mCheckBoxes = new Vector();
        CheckBoxListener mCBListener = new CheckBoxListener();    
        public MyScreen() {
            for (int i = 0; i < mCheckBoxesCount; i++) {
                CheckboxField cb = new CheckboxField(String.valueOf(i), false);
                cb.setChangeListener(mCBListener);
                add(cb);
                mCheckBoxes.addElement(cb);
            }
        }    
        class CheckBoxListener implements FieldChangeListener {
            boolean mProgrammatic = false;
            public void fieldChanged(Field field, int context) {
                if (!mProgrammatic) {
                    mProgrammatic = true;
                    CheckboxField cbField = (CheckboxField) field;
                    int index = mCheckBoxes.indexOf(cbField);
                    if (cbField.getChecked()) {
                        for (int i = 0; i < index; i++)
                            ((CheckboxField) mCheckBoxes.elementAt(i))
                                    .setChecked(true);
                    } else {
                        for (int i = index; i < mCheckBoxesCount; i++)
                            ((CheckboxField) mCheckBoxes.elementAt(i))
                                    .setChecked(false);
                    }
                    mProgrammatic = false;
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have the attached code snippet where a category checkbox is checked if
I'm trying to use a select all checkbox to select a column of checkboxes.
I don't want to rely on the one-click installer any more, and I want
Is it possible, using actionscript 3 to disable the right click menu? Any help
When a user have changed something in a form, then clicks on any link
Is there any way to force a listview control to treat all clicks as
1) when i clicked to any checkbox, a) i want to select radio in
I have a table with a select all checkbox as the first header column
I have 5 checkboxes in each row. The first one is 'ALL'. I am
In WPF, C# application, I have 4 checkboxes, select all team personal subteam. As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.