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

a5v10: Java Character Counter

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

    a5v10: Java Character Counter

    I need help with code for java client side event. While typing text into a "text area" field, the code should work as a counter, count the characters on each key stroke and show the number of characters on another field. The number of characters changes at the client side on each key stroke.

    Any help?

    #2
    Re: a5v10: Java Character Counter

    I probably don't need to remind you that you want javascript, not java.

    The best I could do on short notice is the following:

    Create an unbound field where you want the counter to show (I called my QTY)
    In the field whose length you want to count (I called mine ITEM), add this to the inline java script on the onKeyPress event:
    var myString = {grid.Object}.getValue('G','ITEM',{Grid.RowNumber});
    var vNum = myString.length;
    var vNum = vNum +1;
    {grid.Object}.setValue('G','QTY',{Grid.RowNumber},vNum);
    Remember, javascript is case sensitive.

    See if that works.

    It does not work quite correctly if you press the backspace key and delete some of the characters, but if you start adding characters after the deletion, it does correct the count immediately.
    I hope this helps.
    Jay
    Jay Talbott
    Lexington, KY

    Comment


      #3
      Re: a5v10: Java Character Counter

      here is an example for javascript

      function countWords(){
      document.form1.wordcount.value = document.form1.inputString.value.split(' ').length;
      }

      Place the following code in the document body:

      <form name="form1" method="post">
      <textarea name="inputString" cols="50" rows="4">Text to count</textarea>
      <br>
      <input type="button" name="Convert" value="Count Words" onClick="countWords();">
      <input name="wordcount" type="text" value="" size="6">
      </form>

      there more examples google " javascript character count "

      hope this helps

      Comment


        #4
        Re: a5v10: Java Character Counter

        @Jay Talbott, Javascript and not java. Thanks :)
        I have followed your instruction but it does not work pls. However, I did not use an unbound field because the data in the "Qty" field (that is, the final count) also has to be submitted.

        @bea2701, your code looks to me like raw javascript fto be directly inserted into web a page. I'm sorry, I forgot to add that I'm using a grid component.

        Please see the attached, where I used Jay Tablott's code but which did not work.

        Comment


          #5
          Re: a5v10: Java Character Counter

          Change the QTY field from a label to a text box, and put 1=2 in the enable expression.
          It will then work.
          Best of luck,
          Jay
          Jay Talbott
          Lexington, KY

          Comment


            #6
            Re: a5v10: Java Character Counter

            Thanks Jay,

            It works just the way you said, (the backspace and delete keys don't count). Can we add one or two more codes to make the backspace and delete keys count?.


            Also, it works it does not work on firefox browser but it works on Internet explorer.

            Bless you.

            Comment


              #7
              Re: a5v10: Java Character Counter

              Move the script below to the onKeyUp event.
              (Note: using the onKeyUp event eliminates the need for the line I have remmed out with the //. Also, space bar strokes show up in the count.)

              var myString = {grid.Object}.getValue('G','ITEM',{Grid.RowNumber});
              var vNum = myString.length;
              //var vNum = vNum +1;
              {grid.Object}.setValue('G','QTY',{Grid.RowNumber},vNum);
              It works in my firefox browser.
              Jay
              Jay Talbott
              Lexington, KY

              Comment


                #8
                Re: a5v10: Java Character Counter

                @Jay, you are simply great!

                The space and delete keys now count. I feel good. However, I'll have to check why it's not working in my fire fox and Google chrome. It works fine in Internet explorer.

                Before we close this thread, please let us try one more thing. Let's add one more field and call it "pages". This field value changes to "1" when the user starts typing and if the "Qty" field value increases above 160, the value of "page" field changes to "2" and again to "3" after exceeding an additional 160 characters.

                Comment


                  #9
                  Re: a5v10: Java Character Counter

                  Thanks, that is very nice of you to say.
                  How about you try and figure this out.
                  This is the part where you get to eat for life, not just for a day <grin>.
                  Jay
                  Jay Talbott
                  Lexington, KY

                  Comment


                    #10
                    Re: a5v10: Java Character Counter

                    Hint # 1. Look up the Math.ceil() javascript function.
                    Hint # 2. You only need to add two more lines of code to the above script.
                    Jay
                    Jay Talbott
                    Lexington, KY

                    Comment


                      #11
                      Re: a5v10: Java Character Counter

                      Give me fish and you feed me for one day, but teach me how to fish and you feed me for all days.:)

                      Let me try.

                      Comment


                        #12
                        Re: a5v10: Java Character Counter

                        I've been all over the place searching for the past 4 hours.

                        The say ceiling "Returns the smallest integer that is greater than or equal to the specified Number". I've tried many potions but none of them worked. Pls help!

                        Comment


                          #13
                          Re: a5v10: Java Character Counter

                          var myString = {grid.Object}.getValue('G','ITEM',{Grid.RowNumber});
                          var vNum = myString.length;
                          var vPages = Math.ceil(vNum/160);
                          {grid.Object}.setValue('G','QTY',{Grid.RowNumber},vNum);
                          {grid.Object}.setValue('G','PAGES',{Grid.RowNumber},vPages);
                          Notice I have added a field called Pages.

                          See how that works out.
                          Jay
                          Jay Talbott
                          Lexington, KY

                          Comment


                            #14
                            Re: a5v10: Java Character Counter

                            Thanks a lot Jay. Everything works real fine and it's started working in my firefox and google chrome too. Big "Cheers' to you.

                            Comment


                              #15
                              Re: a5v10: Java Character Counter

                              In case it matters - What count would you expect for the following (four lines, no line return after the '4'):

                              1
                              2
                              3
                              4

                              Should that be counted as 4, or perhaps 7 including one count for each hard return? It unfortunately counts as 10 with the latest javascript in this discussion.
                              Steve Wood
                              See my profile on IADN

                              Comment

                              Working...
                              X