Send input data on change from HTML to Client Script in Service Portal Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2022 07:29 PM
Hello,
We have a service portal widget that I need to enhance. One of the things I need to do is send input data from the HTML to the Client Script without any button click. Once the input data has been populated (text entry) and the user clicks on the next input field, that data should be readily available on the client side for further processing.
What I have so far but is not working:
HTML:
<label>Enter Number of Occurrences</label><br/>
<input id="input-num" ng-model="numOccurences" onchange="numOcc()"><br/>
Client Script:
function($scope, $sce, spModal, $rootScope, $window, $filter,spUtil) {
var c = this;
c.numOcc = function() {
var occurences = document.getElementById('input-num').value;
alert(occurences); //This is not alerting any value
}
}
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2022 12:00 AM
try something like this.
not tested though, might need to be tweaked a bit.
<input id="input-num" ng-bind="data.numOccurences" onchange="numOcc()"><br/>
c.numOcc = function() {
alert($scope.data.numOccurences); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2023 10:52 AM
Were u able to find how to do this correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2023 01:16 PM
Old Thread, but from first glance this actually looks okay, however the key error is that onchange="numOcc()" is incorrect. It should be ng-change="c.numOcc()" (granted, that the widget is configured with controllerAs = c - which is the default configuration).