
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 07:29 AM
Hi All,
I am returning an array from script include to Onchange client script where I need to popup it using g_form.addinfomessage, but its showing in one line.
I want to show each value in a separate line. like
Info:
ABC
XYZ
LMN
I used '\n', but no luck.
How to show array values in a separate new lines?
Thanks,
Virendra
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 08:03 AM
Hi @Virendra K,
You can do this in two ways:
1. Join the array values with <br/> to insert line breaks between each value:
// Assuming you're getting an array from the Script Include
var myArray = ['ABC', 'XYZ', 'LMN'];
// Join the array values with a line break
var message = 'Info:<br/>' + myArray.join('<br/>');
// Display the message with each value on a new line
g_form.addInfoMessage(message);
2. Using for each, to separate lines:
// Assuming you have the array returned from Script Include
var myArray = ['ABC', 'XYZ', 'LMN'];
// Initialize the message with the desired text
var message = 'Info:<br/>';
// Add each array value to a new line
myArray.forEach(function(item) {
message += item + '<br/>';
});
// Displays the formatted message
g_form.addInfoMessage(message);
If my answer helped you in any way, please mark it as correct/helpful 🙂
Regards,
Isaac Vicentini.
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 07:38 AM
1.test your output of SI using alert(); where you use '\n'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 08:03 AM
Hi @Virendra K,
You can do this in two ways:
1. Join the array values with <br/> to insert line breaks between each value:
// Assuming you're getting an array from the Script Include
var myArray = ['ABC', 'XYZ', 'LMN'];
// Join the array values with a line break
var message = 'Info:<br/>' + myArray.join('<br/>');
// Display the message with each value on a new line
g_form.addInfoMessage(message);
2. Using for each, to separate lines:
// Assuming you have the array returned from Script Include
var myArray = ['ABC', 'XYZ', 'LMN'];
// Initialize the message with the desired text
var message = 'Info:<br/>';
// Add each array value to a new line
myArray.forEach(function(item) {
message += item + '<br/>';
});
// Displays the formatted message
g_form.addInfoMessage(message);
If my answer helped you in any way, please mark it as correct/helpful 🙂
Regards,
Isaac Vicentini.
MVP 2025 ✨