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

Javascript to highlight current field text

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

    Javascript to highlight current field text

    I can't quite figure out the javascript to highlight the current input text control contents. I'm using the OnFocus event and while I'm returning the correct vname, it doesn't work:

    Code:
    var vname = '{grid.Object}.V.R' + {Grid.RowNumber} + '.VENDORNAME';
    document.getElementById(vname).select();
    Any ideas?
    -Steve
    sigpic

    #2
    Re: Javascript to highlight current field text

    Code:
    $(this).select();
    Seems to work for both grids and dialogs.
    Jim Coltz
    Alpha Custom Database Solutions, LLC
    A5CustomSolutions.com
    [email protected]

    Comment


      #3
      Re: Javascript to highlight current field text

      Yup, works nicely Jim, thanks. I came close to that a time or two but close only counts in horseshoes, hand grenades, bumper pool, cement work and nuclear war.
      -Steve
      sigpic

      Comment


        #4
        Re: Javascript to highlight current field text

        Well they must have changed something in V12 as it does not work properly in dialog or grid.

        Comment


          #5
          Re: Javascript to highlight current field text

          Originally posted by MRTankle View Post
          Well they must have changed something in V12 as it does not work properly in dialog or grid.
          What version of 12? What browser? What does your code look like?

          I tried the code below and things appear to work just fine in a grid & a UX:
          Code:
          $(this).select();
          But maybe my version is not the same as yours? 12.3 Build 2128

          It should be noted that the code in the OP should say {grid.ComponentName}, not {grid.Object}, when specifying the ID for the text area.
          Alpha Anywhere latest pre-release

          Comment


            #6
            Re: Javascript to highlight current field text

            I have a field, for example, on the second pane of the detail section of a grid.
            • defined as testbox
            • display format is pre-defined $123,456.78
            • client side properties checked - type number
            • format definition: number can be blank; blank is 0, thousands separator
            • in OnFocus I placed $(this).Select();

            When the field displays the amount of 32.89 properly shows as $32.89.
            When I tab into the field, the dollar sign goes away and the cursor is between the 3 and the 2.
            What I want to happen is have the whole field selected, so if I type in a new number the entire previous number is removed. So if I type in an 8, I wind up with 382 instead of just an 8
            I realize the little x is there to clear the field, but that's not normal entry.
            I hope I made myself clear. TIA.

            Comment


              #7
              Re: Javascript to highlight current field text

              Originally posted by MRTankle View Post
              in OnFocus I placed $(this).Select();
              Did you capitalize select()? JavaScript is case sensitive. So, $(this).Select() would be an error. You should have $(this).select();
              Alpha Anywhere latest pre-release

              Comment


                #8
                Re: Javascript to highlight current field text

                $(this).select(); is what I have.

                Comment


                  #9
                  Re: Javascript to highlight current field text

                  Okie dokie. I made the changes you listed here & get similar behavior in both V11 and V12, so this isn't anything new.

                  Alpha has some event listeners setup that execute on focus when you have a mask defined for a text box. These remove the $ and thousand separator (and whatever else needs to go) from the number before permitting data entry. These pre-parsing functions are calling A5.edit.setSelection, which is probably happening after your select() is called --- so, that's going to undo all your work.

                  You could try wrapping the select call in a setTimeout. There will be a slight delay with the highlighting. You may be able to change 100 to a smaller value. It depends on how much time it takes the client's browser to execute the other event handlers:

                  Code:
                  setTimeout(function (){ $('{grid.componentName}.V.R{grid.rowNumber}.FIELD_NAME').select(); }, 100);
                  If having a delay is bothersome, then you could write your own bit of code to pre-parse & set the value in the field before calling select() in the onFocus event --- eg, doing what alpha is already doing for you when removing the $ and , from the field before allowing data entry. You would no longer need setTimeout. Alpha has encapsulated all masking & parsing code in the {grid.object}._fieldHelpers_G['FIELD_NAME'] object. Look at _editFocus and see what's going on in there. You should be able to figure out how to replicate the same functionality with quite a bit of investigation.

                  Or, you could just be really really lazy and copy-paste the entire _editFocus function and replace all instances of A5.edit.setSelection(ele, sel.start) with ele.select(). You'd put this in one of your client-side events, like... onGridRenderComplete or something (somewhere after the field helpers object has been defined & initialized.)
                  Code:
                  {grid.object}._fieldHelpers_G['FIELD_NAME']._editFocus = function(e, ele) {
                          this._editTargetId = ele.id;
                          // omitted code for brevity; you actually want to copy the entire function here and only modify the 2 A5.edit.setSelection lines
                  
                          if (this.format.type == 'mask') {
                                  // omitted code...
                  
                                  ele.select();//A5.edit.setSelection(ele, sel.start);
                                  // more omitted code...
                          } else if (this.format.type == 'number') {
                              // omitted code...
                  
                              ele.select();//A5.edit.setSelection(ele, sel.start);
                          }
                  };
                  You'll want to retrieve the full function from alpha's A5.Edit class. Search for the _editFocus function inside the A5.Edit.prototype definition in alpha's published .js files for your grid. The file will be named something like a5-23945478.js (the number part will be different on your end.) Your _editFocus function definition may be different from mine, so you'll want to look it up yourself. Chrome has a make pretty button that makes it easier to read alpha's js files, but it might not be necessary. Alpha didn't minify the entire file, so a lot of the A5 javascript is already readable.

                  Have fun!
                  Alpha Anywhere latest pre-release

                  Comment

                  Working...
                  X