Question

How to identify the element that triggered the event in JavaScript
Hi All,
I have configured 'Run Script' action on 'Change' event for a RTE (Rich Text Editor) Control. Now, I want the inner text of the element that generated the event.
I have tried using 'event.target' but this is not letting my JavaScript execute altogether may be because it there is no 'onchange' attribute created. Instead, 'data-change' attribute is created.
The requirement is I have to calculate remaining characters (Max being 2000) and show it to the user on the fly. PFA doc for design screenshots.
Can somebody help me on this?
Thanks in advace.
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Like (0)
-
Accepted Solution

Hi giridhar,
Can you go for onchange datatransform(containing logic to get remaining char count) and set a param or propety for counter and use it to display count of remaining characters with a refresh.
As it is always recommeded to not to use scripts when possible.

Hi
Have you checked this article ?

I have to implement it in Rich Text Editor control.

Hi All,
Can anybody help me with the above issue?
Thanks in advance.

Could you please try the below code snippet and retest the scenario.
Could you please try the below code snippet and retest the scenario.
<input disabled maxlength="3" size="3" value="10" id="counter"> <textarea onkeyup="textCounter(this,'counter',10);" id="message"> </textarea> <script> function textCounter(field,field2,maxlimit) { var countfield = document.getElementById(field2); if ( field.value.length > maxlimit ) { field.value = field.value.substring( 0, maxlimit ); return false; } else { countfield.value = maxlimit - field.value.length; } } </script>

Hi All,
Can anybody help me with the above issue?
Thanks in advance.
Accepted Solution

Hi giridhar,
Can you go for onchange datatransform(containing logic to get remaining char count) and set a param or propety for counter and use it to display count of remaining characters with a refresh.
As it is always recommeded to not to use scripts when possible.

Hi AdityaViswanatha,
Thanks for the input.
All this time, I assumed that the changed content would not be reflected in the property referred in RTE but I was wrong.
Now, I am able to implement the same in an activity and refer the remaining character count in a parameter property referring it in the desired section.

Hi Giridhar_Metikal,
Is your implementation displays the remaining Character count at the end or while text is being entered?
My requirement is to show the remaining character count live. Just like the OOTB option that is available for TextArea control.
can you let me know the steps you have created.

Have u added the JS file AdminEntityLetters to your harness? If not the script for the function will not be loaded.