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

Dialog Button

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

    Dialog Button

    I've created a dialog with one object on it - a big button. This is for a user Login/Logout which is not related to A5 basic security. When the user presses the button it should operate like a two-state button i.e. Login, then when pressed, Logout. I wanted the button to change the text and the color so it is obvious to the user what is happening. On each occurrence I need to write some code to capture the time, etc.

    The question I have is can I do this from one dialog or do I have to create two dialogs and then somehow turn them on or off?

    Thanks.

    #2
    Re: Dialog Button

    Charles,

    How about one dialog w. two buttons using a show/hide expression?

    Haven't thought through all the logic. Guess it depends upon your situation.
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com


    Comment


      #3
      Re: Dialog Button

      That's where I was heading too. Picture of webpage attached. What I did was create a control with two buttons. On the show/hide I put a session variable like session.loginout=.T. On the other button, I put the reverse. On the OnClick event I put XBasic Server-Side code which reversed the logical. BTW, you have to address the session.loginout in caps like SESSION.LOGINOUT or it won't work.

      Interesting problem that arises is that at times the button seems to depress, but doesn't change. Other times, (with a deliberate push) it will. Not sure why that is happening.

      More to come.

      LoginOut.gif

      Comment


        #4
        Re: Dialog Button

        Hi Charles. I tested this out in V12 but I think it should work with V11 as well.

        This is an example using a SINGLE button.

        I created a button and then in it's properties under "button Text" I put in the following:
        Code:
        <div id = "LILOBUTTON">Login</div>
        Next I made a textbox field (which you can hide later of course) named bttst I set it to be a logical field.
        In the textbox properties I set the default value to be 1, or "true"
        Next, in the buttons, onclick event I converted it to text mode and put in this javascript:

        Code:
        var bttst = {dialog.Object}.getValue('BTTNST');
        
        if (bttst==true){
        
        	$('LILOBUTTON').innerHTML='LOGOUT';
        	{dialog.Object}.setValue('BTTNST',2);
        }
        else{
        
        	$('LILOBUTTON').innerHTML='LOGIN';
        	{dialog.Object}.setValue('BTTNST',1);
        }
        Then I set the client side conditional style of the button to turn green if bttntst is true and red if it's false.


        The code checks for the condition of the last click. Of course you can put any other code you want in there that you have to execute. You cal also break up the if/else statement into action javascript inline javascript commands instead of using text mode so you can have other action javascript commands in or around it if it's easier for you.

        In any case; using the above, the login button's text will change to logout and back to login as clicked and the background color of the button changes as well.

        Hopefully this helps and is somewhat what you want.

        Here's a quick video of the component behavior:

        http://screencast.com/t/uaw2kWsuA
        Last edited by -Jinx-; 03-13-2014, 12:55 PM.

        Comment


          #5
          Re: Dialog Button

          Wow! Thanks. I'll work on this and let you know how it goes.

          Thanks so much.

          Comment


            #6
            Re: Dialog Button

            I set this up and tested it out. Just for clarification, in paragragh 2 you said you set the textbox name to "bttst" but I think you mean "bttnst". I'm just making a note for someone else (not complaining).

            One other thing, that might prove helpful. How can I put some static text under the button, where, based on the button push it says different things, such as "Good job at logging out", etc.? I've also thought of adding a JS pop-up informing the user that the login/logout was successful or not. I'm not sure how to address the static text properties though.

            Once again, thanks for going to the trouble of producing the video. That was really awesome!

            Comment


              #7
              Re: Dialog Button

              Yeah, I got confused on my naming conventions. You're right.

              As for the static text. I personally would use a div again. It all depends on what you'd like to do.

              For instance, you can make a free-form container and in it's free-form layout put in somthing like this:
              Code:
              <div id = "MSGDIV"></div>
              Then in the button code you can basically copy a line and use the MSGDIV instead of the button one. This will change the internal html of the free-form div.

              Code:
              var bttst = {dialog.Object}.getValue('BTTNST');
              
              if (bttst==true){
              
              	$('LILOBUTTON').innerHTML='LOGOUT';
              	{dialog.Object}.setValue('BTTNST',2);
              	[COLOR="#FF0000"]$('MSGDIV').innerHTML='You are now logged in';[/COLOR]
              	
              }
              else{
              
              	$('LILOBUTTON').innerHTML='LOGIN';
              	{dialog.Object}.setValue('BTTNST',1);
              	[COLOR="#FF0000"]$('MSGDIV').innerHTML='You are now logged out';[/COLOR]
              	
              	
              	
              }
              That's just one way to do it. You could hide or show a DIV or container as well. For instance, you could make a container at the bottom of all your controls and set it to hidden. Then there is an action javascript to "Toggle display of a container or a DIV with animation".
              Last edited by -Jinx-; 03-13-2014, 03:06 PM.

              Comment


                #8
                Re: Dialog Button

                All of this is great. However, I am using V11 and it does not have the feature of changing the color properties. Is there a way of changing these properties in the JS?

                Thanks.

                Comment


                  #9
                  Re: Dialog Button

                  I just checked my version 11 and it does indeed have the color properties. My build is 3381-4096

                  "conditional style, text and events" is the name under button properties in V11

                  Comment


                    #10
                    Re: Dialog Button

                    If for some reason your build doesn't have it, Something like this will work:

                    Code:
                    $('LILOBUTTON').style.backgroundColor = 'Red';
                    You'll probably see that it misses a little around the periphery of the button. I think that has to do with the corners and such being an image or something in the CSS. definitely better to use the style setting if you have it.

                    Comment


                      #11
                      Re: Dialog Button

                      Originally posted by Charles Hoens View Post
                      All of this is great. However, I am using V11 and it does not have the feature of changing the color properties. Is there a way of changing these properties in the JS?

                      Thanks.
                      Yes.

                      You can use the add/remove class name functions:

                      Code:
                      $acn('ELEMENT_ID','CLASS_TO_ADD');
                      $rcn('ELEMENT_ID','CLASS_TO_REMOVE');
                      Or the set style functions:
                      Code:
                      $ss('ELEMENT_ID',{backgroundColor: 'red', fontWeight: 'bold'});
                      Both (and more) are documented here: http://wiki.alphasoftware.com/~alpha...+in+Version+10

                      PS:

                      $svs can be used to set the element's HTML:
                      Code:
                      $svs('ELEMENT_ID','This is the HTML to go inside');
                      Alpha Anywhere latest pre-release

                      Comment


                        #12
                        Re: Dialog Button

                        Sarah,
                        Some of the code in your post doesn't seem to work right with buttons. I tried it in V11 and V12.

                        Considering a button with the id of BUTTON_2:

                        Code:
                        $ss('BUTTON_2',{backgroundColor: 'red', fontWeight: 'bold'});
                        Doesn't work with the button ID, as in 'BUTTON_2'. You'd have to add the prefixes of DLG1.V.R1. in front of the ID
                        However, if you run something like this:
                        V12:
                        Code:
                        var ele = {dialog.Object}.getPointer('BUTTON_2');
                        $ss(ele,{backgroundColor: 'red', fontWeight: 'bold'});
                        OR V11 and V12
                        Code:
                        $ss('DLG1.V.R1.BUTTON_2',{backgroundColor: 'red', fontWeight: 'bold'});
                        or a shortcut which seems to work for both if you are using the code in the events of the button that you want to change:
                        Code:
                        $ss(this,{backgroundColor: 'red', fontWeight: 'bold'});
                        In all those cases, it will only change the color in a square around the periphery of the button. (which is the opposite of what I had above with my code to change the background since I had a div in the button.)

                        So now that I've figured it out, finally, you can use these in V11 and V12

                        Code:
                        $ss('DLG1.V.R1.BUTTON_2',{background: 'Red',backgroundColor: 'red', fontWeight: 'bold'});
                        if it's in the buttons events:
                        Code:
                        $ss(this,{background: 'Red',backgroundColor: 'red', fontWeight: 'bold'});
                        OR
                        Code:
                        $(this).style.backgroundColor = 'Red'
                        $(this).style.background= 'Red'
                        OR finally this:
                        Code:
                        $('DLG1.V.R1.BUTTON_2').style.backgroundColor = 'Red'
                        $('DLG1.V.R1.BUTTON_2').style.background= 'Red'
                        Last edited by -Jinx-; 03-14-2014, 01:00 PM.

                        Comment


                          #13
                          Re: Dialog Button

                          Originally posted by -Jinx- View Post
                          Doesn't work with the button ID, as in 'BUTTON_2'. You'd have to add the prefixes of DLG1.V.R1. in front of the ID
                          'BUTTON_2' is not the element ID of the button. You need to specify the complete object ID. 'ELEMENT_ID' = '{dialog.componentName}.V.R1.FIELD_NAME'. Alpha's JS library operates on the DOM. Sadly, the JS is not pre-compiled to replace things like 'BUTTON_2' with the fully formed ID.
                          Last edited by TheSmitchell; 03-14-2014, 01:05 PM.
                          Alpha Anywhere latest pre-release

                          Comment


                            #14
                            Re: Dialog Button

                            Originally posted by TheSmitchell View Post
                            Yes. 'BUTTON_2' is not the element ID of the button. You need to specify the complete object ID. 'ELEMENT_ID' = '{dialog.componentName}.V.R1.FIELD_NAME'.
                            I didn't see that in the documentation. Maybe I'm blind.

                            Oh, and I just realized you don't need to set both backgroundColor and Background you can just use background:

                            Code:
                            $('DLG1.V.R1.BUTTON_2').style.background= 'Red'
                            OR
                            Code:
                            $ss('DLG1.V.R1.BUTTON_2',{background: 'red'});
                            Or in the buttons onclick:
                            Code:
                            $(this).style.background= 'Red'
                            or this:
                            Code:
                            $ss(this,{background: 'red'});

                            Comment


                              #15
                              Re: Dialog Button

                              Originally posted by -Jinx- View Post
                              I didn't see that in the documentation. Maybe I'm blind.
                              Ah. It's there. It could be called out better, though.

                              The functions below provide an easy way to get and set the in-line style, can class of HTML elements. The passed in argument of "ELEMENT" can be a pointer to an HTML element, or the ID or NAME of an HTML element. The functions will automatically fetch the element if you pass in an ID or NAME.
                              I kinda wish Alpha would use IDs that were distinct from their examples in the documentation for {[dialog|grid].object}.[get|set]Value --- eg, don't reuse "firstname" and "lastname". And also include a short HTML portion on the wiki for the JS library examples. The whole of Alpha's JS library is convenience built on top of the JavaScript document & element API, and also some of Alpha's custom functions.
                              Alpha Anywhere latest pre-release

                              Comment

                              Working...
                              X