Skip to main content
Version: v11.7.1

Using JavaScript to loop a command

Inserting and updating multiple rows into the database table.

insert into Subscriptions(UserId,ChannelId,SubscriptionCost) 

CheckboxSet onChange event

// For handling Selected Channels
var userChannels = [];

Page.checkboxsetSelectedChannelsChange = function ($event, widget, newVal, oldVal) {
// Selected Channels are added
userChannels = newVal;

Loop function through JavaScript

Page.buttonSubscribeClick = function ($event, widget) {
// Check if User selected any channels if YES add them ELSE notify him
if (userChannels.length > 0) {
// Iterating along the selected channels for subscription and adding them
for (let i = 0; i < userChannels.length; i++) {
"UserId": Page.Widgets.selectSelectUser.datavalue,
"ChannelId": userChannels[i],
"SubscriptionCost": "10$"

} else

See Also

How to use JavaScript to Use Expressions for Binding
How to load JavaScript from external URLs
How-To insert/update multiple rows in a database using a FOR loop in JavaScript