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

Set Static Text value with Javascript

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

  • Set Static Text value with Javascript

    Hi, is it possible to set a Static Text text value with JavaScript? The searching that I've done has referred me to innerHTML property. I can't get it to work on a Static Text box and I'm not sure if it is even a property of a Static Text box.

    Thanks. Jason

  • #2
    Re: Set Static Text value with Javascript

    A Static text box does not exist , static text controls & text box controls do exist. To answer your question; yes you can. Just get a pointer to the control with Document.getElementById() & then replace the innerHTML
    Frank

    Tell me and I'll forget; show me and I may remember; involve me and I'll understand

    Comment


    • #3
      Re: Set Static Text value with Javascript

      Thanks for the quick response. I tried doing the following and it didn't work. Using your pointers I searched more on the forums, but could come up with no example that is different than this bit of code.

      var p = document.getElementById('STATICTEXT_1');
      p.innerHTML = '1234';

      Thanks,

      Jason

      Comment


      • #4
        Re: Set Static Text value with Javascript

        Jason,

        You are not using the full ID of the static text control; it's probably like this if you're working in a UX (depends on your component) : 'DLG1.V.R1.STATICTEXT_1'

        A good way to find out is Firebug in Firefox or the Devtools in Chrome (F12) to inspect the element (the static text control in this case): dt.png
        Frank

        Tell me and I'll forget; show me and I may remember; involve me and I'll understand

        Comment


        • #5
          Re: Set Static Text value with Javascript

          try this and see if it works.
          for the static text enter the following as the value
          static text here: <span id="some_id"></span>
          then create a button and onClick event for the button define a inline javascript
          that will be
          Code:
          var id = document.getElementById('some_id');
          id.innerHTML="whatever you want to say here";
          I tested and it works, but I do not how you exactly call the javascript function.
          thanks for reading

          gandhi

          version 11 3381 - 4096
          mysql backend
          http://www.alphawebprogramming.blogspot.com
          [email protected]
          Skype:[email protected]
          1 914 924 5171

          Comment


          • #6
            Re: Set Static Text value with Javascript

            That worked. Thanks for the assist Frank. And the recommendation on Firebug.

            This is the JavaScript code that is working:
            document.getElementById('DLG1.V.R1.STATICTEXT_1').innerHTML = '1234';

            Jason

            Comment


            • #7
              Re: Set Static Text value with Javascript

              Originally posted by Jason Penner View Post
              That worked. Thanks for the assist Frank. And the recommendation on Firebug.

              This is the JavaScript code that is working:
              document.getElementById('DLG1.V.R1.STATICTEXT_1').innerHTML = '1234';

              Jason
              Hi Jason,

              It looks like you're working with a UX Component, so you can simplify your code here and use the {dialog.object} setValue() method to set the value in the static text object:

              Code:
              {dialog.object}.setValue('STATICTEXT_1','1234');
              Alpha also has some library javascript functions that can help you write code. Check out $, shorthand for document.getElementById, and $svs, which sets the value of the element with provided ID - similar to setting the innerHTML property:

              Code:
              $svs('DLG1.V.R1.STATICTEXT_1','1234');
              Good luck!
              Alpha Anywhere latest pre-release

              Comment


              • #8
                Re: Set Static Text value with Javascript

                Thanks for the info. Yes I am in the UX.

                I have used getValue and setValue on data controls (switches, checkboxes, radiobuttons, etc.) without issue. But the same code would not work on the Static Text box.

                $svs('DLG1.V.R1.STATICTEXT_1','1234'); works great and I appreciate you letting me know about the shorthand.

                Jason


                ps: how do you embed the code in the box in the message postings?

                Comment


                • #9
                  Re: Set Static Text value with Javascript

                  Originally posted by Jason Penner View Post
                  Thanks for the info. Yes I am in the UX.

                  I have used getValue and setValue on data controls (switches, checkboxes, radiobuttons, etc.) without issue. But the same code would not work on the Static Text box.

                  $svs('DLG1.V.R1.STATICTEXT_1','1234'); works great and I appreciate you letting me know about the shorthand.

                  Jason


                  ps: how do you embed the code in the box in the message postings?
                  Odd that {dialog.object}.setValue did not work. I've used this frequently to set the value in static text controls. What version of Alpha Anywhere are you using?

                  To embed text in a post, use the bulletin board code tags:
                  HTML Code:
                  [code]your code goes here[/code]
                  When you're writing a Post (go "advanced" when in reply mode), click the Button that looks like a #. It inserts the code tags for you.
                  Alpha Anywhere latest pre-release

                  Comment


                  • #10
                    Re: Set Static Text value with Javascript

                    I am surprised to see the code in post number 5 did not work.
                    that is odd.
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    [email protected]
                    Skype:[email protected]
                    1 914 924 5171

                    Comment


                    • #11
                      Re: Set Static Text value with Javascript

                      Using Alpha Anywhere v3.5, Developer Edition, Version 12.3.

                      Where are you running the {dialog.Object}.setValue('STATICTEXT_1','1234'); statement from ? I put it on the OnClick event of a button.

                      Comment


                      • #12
                        Re: Set Static Text value with Javascript

                        So I tried again and I can get the {dialog.Object}.setValue('STATICTEXT_1','1234'); working from both button clicks and JavaScript functions. I'm sure that's a problem between brain, fingers, and keyboard.

                        What is the best way to change the label of a Frame? Using this

                        Code:
                        {dialog.Object}.setValue('frame_name','1234')
                        replaces the whole frame with '1234'.


                        Thanks, Jason

                        Comment


                        • #13
                          Re: Set Static Text value with Javascript

                          Have come across these functions that are reported in debugger and as noted by Sarah, these can be used for getting /setting values. Where are documentation for these located or how would I figure out the usage since I can see that I can perform e.g

                          Code:
                          $gvs.prototype

                          http://screencast.com/t/MlZQtEyJl3q
                          Regards,

                          Kotin Karwak
                          Developer Edition
                          Version 12.3 Build 2684
                          System Addins: Build 4438
                          Build machine Windows Vista
                          Skype: mateso08

                          Comment


                          • #14
                            Re: Set Static Text value with Javascript

                            Originally posted by kotinkarwak View Post
                            Have come across these functions that are reported in debugger and as noted by Sarah, these can be used for getting /setting values. Where are documentation for these located or how would I figure out the usage since I can see that I can perform e.g

                            Code:
                            $gvs.prototype

                            http://screencast.com/t/MlZQtEyJl3q
                            The documentation is in the wiki: http://wiki.alphasoftware.com/Alpha+...+in+Version+10
                            Alpha Anywhere latest pre-release

                            Comment


                            • #15
                              Re: Set Static Text value with Javascript

                              Originally posted by Jason Penner View Post
                              So I tried again and I can get the {dialog.Object}.setValue('STATICTEXT_1','1234'); working from both button clicks and JavaScript functions. I'm sure that's a problem between brain, fingers, and keyboard.

                              What is the best way to change the label of a Frame? Using this

                              Code:
                              {dialog.Object}.setValue('frame_name','1234')
                              replaces the whole frame with '1234'.


                              Thanks, Jason
                              The label for the frame is set inside the legend HTML element inside the frameset for the frame. I don't know of any functions that would let you directly access this as the legend element doesn't have an ID. But you can use jQuery to set it:

                              Code:
                              jQuery('#{dialog.componentName}\\.V\\.R1\\.FRAME_1 legend')[0].innerHTML = "new label";
                              If you wanted to use $svs, set the frame title to some <div> with an id. EG:

                              Code:
                              <div id="{dialog.componentName}.myFrameTitle"></div>
                              Then you can do this:

                              Code:
                              $svs("{dialog.componentName}.myFrameTitle","Some Title");
                              Here's a UX that does this (it also sets the value in a static text control):
                              staticTextButton.zip
                              Last edited by TheSmitchell; 09-04-2015, 04:24 PM. Reason: alternate
                              Alpha Anywhere latest pre-release

                              Comment

                              Working...
                              X