Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

How to limit checkboxes to one exclusive box

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to limit checkboxes to one exclusive box

    With radio buttons, the default condition that is that only one radio button can be selected at a time. There does not seem to be any way to place the same constraint on a collection of checkboxes (or I could not find a way). I would like to use checkboxes, but only allow the user to select one at a time. Is this possible, and if so, how can it be done?
    thanks,
    Brian

    #2
    Re: How to limit checkboxes to one exclusive box

    Hi Brian,

    I'm sure there is a way, (which I dont know about) but that is the whole idea of using Radio buttons where a single result is required.
    Last edited by Keith Hubert; 09-04-2012, 09:54 AM.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    Comment


      #3
      Re: How to limit checkboxes to one exclusive box

      Brian -

      +1 to what Keith says :)

      What you are proposing with a group of check boxes sounds counter-intuitive to good UI/UX and would not be what the user would expect.

      Perhaps if you could elaborate on the context in which these will be used you may be able to get the answers you need :)

      Cheers!
      Lyle
      Cheers!
      Lyle Chamney
      http://www.2ninerniner2.com/
      Websites rebuilt with WordPress
      http://goodcheapfastwebsites.com/
      Complete, ready to install WordPress websites
      http://snifflevalve.com
      WordPress training and tutorials

      Comment


        #4
        Re: How to limit checkboxes to one exclusive box

        What have you got against radio buttons? They are designed to do what you want with no effort on your part. Doing what you want is a lot of time and effort...is it really worth it?
        Pat Bremkamp
        MindKicks Consulting

        Comment


          #5
          Re: How to limit checkboxes to one exclusive box

          I can understand why you want to do this... visually it's kind of nicer in some ways. I've run into many forms that present a list with an instruction to just check one. Quite easy to do. Using the ids of the checkboxes you can turn on and off each checkbox in an array of checkboxes. Thanks to mreyeros for a post found on stackoverflow who's elegant code worked great (and cut mine in half) but didn't allow for a checkbox to be re-checked after being unchecked. I'm assuming a grid... in the onClick event of your checkbox control put this...

          Code:
          toggle(this);
          Then, in the Grid's Javascript Functions section put this...

          Code:
          var previousCheckId;
          function toggle(chkBox) {
              if (chkBox.checked) {
                   if (previousCheckId) {
                        if (previousCheckId == chkBox.getAttribute('id')) {
                        }
                        else {
                             document.getElementById(previousCheckId).checked = false;              	
          			  }                   
          		 }
                   previousCheckId = chkBox.getAttribute('id');
              }
          }
          This keeps track of what was last checked (previousCheckId). If the current checkbox is the same as the last check box, then allow it to stay checked. Otherwise, uncheck the previous checked. Hope that makes sense and helps. EDIT: previousCheckId code line didn't get pasted in... it's there now.
          Last edited by Davidk; 09-04-2012, 12:14 PM.

          Comment


            #6
            Re: How to limit checkboxes to one exclusive box

            Hi David
            I have been looking for this for weeks. Thank you very much! http://msgboard.alphasoftware.com/al...303#post621303
            I do however have a little problem which i hope you can help me with. I have a dialog with 3 repeating sections. Each repeating section has a checkbox field in it. When i run the code you provided it applies it across all 3 repeating sections instead of only with the applicable repeating section. You can look at my post to see what my dialog looks like. I assume that i will have to have 3 separate functions each pointing to the applicable repeating section. Problem is i don't know javascript and no idea how to do this

            Comment


              #7
              Re: How to limit checkboxes to one exclusive box

              Manage to solve the problem. Created 3 functions for each repeating section. Works like charm

              Comment


                #8
                Re: How to limit checkboxes to one exclusive box

                Was just going to look at this... glad it worked out.

                Comment


                  #9
                  Re: How to limit checkboxes to one exclusive box

                  primaryadd.JPG

                  How can this be applied to a Dialog form with a Repeating Section.

                  My field is a checkbox set as logical. The name of the field is Primary.

                  I tried adding the javascript code to the fields OnClick and the xBasic code to the fields Validation Xbasic section property.

                  PrimaryProperties.JPG

                  Comment


                    #10
                    Re: How to limit checkboxes to one exclusive box

                    So you have a repeating section of Addresses... and you want to select one of those addresses as the Primary address. One checkbox checked within a repeating section of checkboxes... and if one is already checked, and you check a different row within the section, the currently checked row will auto uncheck... is that right?

                    Comment


                      #11
                      Re: How to limit checkboxes to one exclusive box

                      You could do a kind of brute force thing...

                      1. Get the number of rows in the repeating section
                      2. Get the current row you're in
                      3. Loop through the rows turning everything off, except the current row.

                      Code:
                      var numRows = {dialog.Object}._getRepeatingSectionRowCount('CONTAINER_1');
                      var currRow = {dialog.Object}.getRepeatingSectionActiveRow('CONTAINER_1', 'true');
                      
                      for (var i=1; i<numRows + 1; i++)
                      { 
                      if (i != currRow){
                      	{dialog.object}.setValue('PRIMARY:' + i, 0);
                      	}	
                      }

                      Comment


                        #12
                        Re: How to limit checkboxes to one exclusive box

                        Yes thats it.

                        Comment


                          #13
                          Re: How to limit checkboxes to one exclusive box

                          Is this code for on click event of the Primary field ?

                          Comment


                            #14
                            Re: How to limit checkboxes to one exclusive box

                            Yes... the code goes into the onClick event of the Primary field.

                            I was thinking about the code a bit and feel it's doing too much work. Specially when you consider that performing a setValue actually dirties the row... and for every row, except two, you don't need to do that. Probably would result in way more server stuff going on than needed. So, in that light, I think this is a bit better...

                            Code:
                            var numRows = {dialog.Object}._getRepeatingSectionRowCount('CONTAINER_1');
                            var currRow = {dialog.Object}.getRepeatingSectionActiveRow('CONTAINER_1', 'true');
                            
                            for (var i=1; i<numRows + 1; i++)
                            	{ 
                            	if (i != currRow){
                            		currValue = {dialog.Object}.getValue('PRIMARY:' + i);
                            		if (currValue==true){
                            			{dialog.object}.setValue('PRIMARY:' + i, false);
                            			}	
                            		}
                            	}
                            Now... loop through the rows... if the row in the loop is not the same as the current Row, then check first to see if it is checked. If it is checked, then uncheck it. If the Row is not checked then we don't have to worry about it... just leave it alone. And I'm using "true" and "false" to test and set the Logical value... just to make things really clear.

                            Comment


                              #15
                              Re: How to limit checkboxes to one exclusive box

                              David, thanks for the updated code.
                              I put this in the Primary click event. Its not working because I can select all records primary. Is there more code I need to put somewhere ?

                              PrimaryClick.JPG

                              Comment

                              Working...
                              X