907
Views
17
Comments
Re : Count textbox characters.
Question
hi everyone. i  wnated to count the number of characters beside the textbox. can anybady help me how to do it.


Regards,
sattibabu vatti.
2019-06-17 07-29-54
Hermínio Mira
sattibabu vatti wrote:
hi everyone. i  wnated to count the number of characters beside the textbox. can anybady help me how to do it.


Regards,
sattibabu vatti.
 
 Hi,

You can use the Length() function with the variable associated with the textbox.

Cheers,
Hermínio Mira
UserImage.jpg
Sattibabu Vatti
hi
can u explain with example.


Regards,
sattibabu vatti.
2018-09-07 11-54-27
Eric Oud Ammerveld
I've actually created a widget that does that but using an Ajax refresh it's terribly slow.
It's best to create your own widget in combination with a simple Javascript that does the job.
Below my solotion; it might help you out:



2018-09-07 11-54-27
Eric Oud Ammerveld
The key function actually is the onkeypress event which calls a refresh function of the "Nog 1000 karakters over" (Dutch for : "1000 characters left)
Combined with the expression calculation of the resulting count this gives you the 'counter'
 
This worked terrible because of the refresh in a popup that made the whole screen blink.
Outsystems fixed that in a later 6.0.x.x version.

Hope it helps!

Cheers,

Eric
UserImage.jpg
Sattibabu Vatti
hi,

can u expalin calcualteCharacterLeft Screen Action?

Regards,
sattinbabu vatti.
2018-09-07 11-54-27
Eric Oud Ammerveld
That's actually nothing but a 'Ajax refresh' of the ShowCharLeft expression.
UserImage.jpg
Sattibabu Vatti
hi,

 can u tell me what is the initial value datatype?

Regards,
sattibabu vatti.

2018-09-07 11-54-27
Eric Oud Ammerveld
It's a text type; the "initial" content of your Input textbox.
2011-06-15 10-51-22
Joop Stringer
Check out this neat little (jQuery) solution
https://stackoverflow.com/questions/5371089/jquery-count-characters-in-textarea


<script>
        function countChar(val){
                                var len = val.value.length;
                                if (len >= 500) {
                                    val.value = val.value.substring(0, 500);
                                }else {
                                    osjs('#charNum').text(500 - len);
                                }
        };
    </script>
 
<textarea id="field" onkeyup="countChar(this)"></textarea>
<div id="charNum"></div>
UserImage.jpg
Sattibabu Vatti
hi,


 i created screen action. but iam not able to get those screen action in to the input  prpperties  value1 in extended prpperties .can u tell me how to get it.


regards,
sattibabu vatti.
2018-09-07 11-54-27
Eric Oud Ammerveld
Ok, check this link to download the widget.

You'll need to have at least Service Studio 6.0.0.9 to open the OML.
2018-09-07 11-54-27
Eric Oud Ammerveld
@sattibabu did that help you?
UserImage.jpg
Sattibabu Vatti
hi,

yes. it is helping me. i  added  that in create a new form. i did it. but after enter tha data i  want to save it. how to save it.


Regards,
sattibabu vatti.
2018-09-07 11-54-27
Eric Oud Ammerveld
In the Save (Opslaan) screenaction the widget has a NotifyWidget action.
This passes the data you've entered in the input field to the calling Webscreen.

In the calling Webscreen you should point the On Notify Destination to a (new) screen action.


In this screen action you can retrieve the data that is passed by the widget using the NotifyWidgetGetMessage() Function / Action.


This method is a generic way for widgets to pass data to the calling Webscreen or to notify the calling Webscreen.
HINT: Try some existing Outsystems apps; to learn on the interaction with widgets.
2021-04-22 08-17-01
Luis Soares
sattibabu vatti wrote:
hi everyone. i  wnated to count the number of characters beside the textbox. can anybady help me how to do it.


Regards,
sattibabu vatti.
 
 Hello,

If you feel confortable and interesed on jQuery, i would recomend you the following jQuery sample code that you need to adapt to your textarea:
https://learnagile.blogspot.pt/2012/05/jquery-textarea-character-count.html

If you need a webblock with the code i can provide it later.

UserImage.jpg
Jere Vatka

The super-simple way to do this is by using the input variable you have in your text area:

1. Create an expression below your text area

2. Expression should state:  Length(variable) + " / 250" (Note that in this case the max length is 250, swap it as you please)

3. Customize it as you please

2019-06-17 07-29-54
Hermínio Mira

Jere Vatka wrote:

The super-simple way to do this is by using the input variable you have in your text area:

1. Create an expression below your text area

2. Expression should state:  Length(variable) + " / 250" (Note that in this case the max length is 250, swap it as you please)

3. Customize it as you please

Hi Jere,


I'm assuming you would use the onChange property to do an ajax refresh and update this expression, right? 

If you see my answer from 2012 it was along the same idea as yours, but this would mean that you are doing round trips to the server every time the user presses a key, and this is less than desirable.

So going with a client side solution is much better in terms of performance.


Cheers,

Hermínio


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.