- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2015 07:48 PM
I have wrote a script include for an array outcome. I am calling the same script include through a client script. What I need is to get an alert/pop-up alert to display the result of the same array. How can that be achieved?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 04:11 AM
Hi Kunal,
Instead of alerting it in the loop just add it and display it after the loop's finished:
- function _processResponse(response) {
- var userAttributes = response.responseXML.getElementsByTagName("userAttributes"),
- sStringToAdd = "",
- sAnswer = "";
- for (var i=0; i<userAttributes.length; i++){
- sStringToAdd = i<userAttributes.length - 1 ? userAttributes[i].getAttribute("value") + "," : userAttributes[i].getAttribute("value") + "";
- sAnswer += sStringToAdd;
- }
- alert(sAnswer);
- }
Cheers
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 02:33 AM
- var userAttributes = response.responseXML.getElementsByTagName("userAttributes");
- for (var i=0; i<userAttributes.length; i++){
- alert(userAttributes[i].getAttribute("value"));
what to add to the above code to get the comma separated result

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 02:50 AM
Just use a normal array at server side instead of Json and return it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 03:08 AM
I am exactly using the code given by Berny. It is able to fetch the answer.
- function _processResponse(response) {
- var userAttributes = response.responseXML.getElementsByTagName("userAttributes");
- for (var i=0; i<userAttributes.length; i++){
- alert(userAttributes[i].getAttribute("value"));
- }
- }
It is showing :
Alert(INC0000001)
Alert(INC0000001)
I need:
alert(INC0000001,INC0000002)
so I need to know what needs to be added to the above code(client side) to get the required answer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 03:10 AM
I am exactly using the code given by Berny. It is able to fetch the answer.
- function _processResponse(response) {
- var userAttributes = response.responseXML.getElementsByTagName("userAttributes");
- for (var i=0; i<userAttributes.length; i++){
- alert(userAttributes[i].getAttribute("value"));
- }
- }
It is showing :
Alert(INC0000001)
Alert(INC0000002)
I need:
alert(INC0000001,INC0000002)
so I need to know what needs to be added to the above code(client side) to get the required answer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 04:11 AM
Hi Kunal,
Instead of alerting it in the loop just add it and display it after the loop's finished:
- function _processResponse(response) {
- var userAttributes = response.responseXML.getElementsByTagName("userAttributes"),
- sStringToAdd = "",
- sAnswer = "";
- for (var i=0; i<userAttributes.length; i++){
- sStringToAdd = i<userAttributes.length - 1 ? userAttributes[i].getAttribute("value") + "," : userAttributes[i].getAttribute("value") + "";
- sAnswer += sStringToAdd;
- }
- alert(sAnswer);
- }
Cheers
Greg