Question
BlueRose Technologies
AU
Last activity: 4 Oct 2018 13:54 EDT
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)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Accenture
SG
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.
Pegasystems Inc.
IN
Hi
Have you checked this article ?
BlueRose Technologies
AU
I have to implement it in Rich Text Editor control.
Blue Rose Technologies GmbH
BE
Yes Giridhar
BlueRose Technologies
AU
Hi All,
Can anybody help me with the above issue?
Thanks in advance.
IN
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>
BlueRose Technologies
AU
Hi AjitK414,
In your code snippet, how do you pass "this" object to a JS function in Pega?
I have tried as per below screenshot but it is taking as a string ("this"). When I passed nothing to parameter value, it is taking as blank ("").
BlueRose Technologies
AU
Hi All,
Can anybody help me with the above issue?
Thanks in advance.
Accepted Solution
Accenture
SG
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.
BlueRose Technologies
AU
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.
Infosys Limited
DE
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.
Cognizant
GB
Have u added the JS file AdminEntityLetters to your harness? If not the script for the function will not be loaded.