Custom current selections


/ Published in: JavaScript
Save to your folder(s)

This is the code for listing out the current selections.


Copy this code and paste it in your HTML
  1. app.getList("CurrentSelections", function(reply) {
  2.  
  3. selectionslist ="";
  4.  
  5. var mySelectedFields = reply.qSelectionObject.qSelections;
  6.  
  7. console.log(mySelectedFields);
  8.  
  9. //loop through selected fields
  10. var mySelectedFields_arrayLength = mySelectedFields.length;
  11. for (var i = 0; i < mySelectedFields_arrayLength; i++) {
  12.  
  13. var text = mySelectedFields[i].qField + " ";
  14.  
  15. //console.log(mySelectedFields[i].qField);
  16.  
  17.  
  18. if(mySelectedFields[i].qLocked==true) {
  19. var labeltype = 'label label-warning'
  20. } else {
  21. var labeltype = 'label-success';
  22. }
  23.  
  24. console.log(mySelectedFields[i].qLocked);
  25.  
  26. //loop through selected field values
  27. var currentFieldValues = mySelectedFields[i].qSelectedFieldSelectionInfo
  28.  
  29.  
  30. var currentFieldValues_arrayLength = currentFieldValues.length;
  31.  
  32. for (var y = 0; y < currentFieldValues_arrayLength; y++) {
  33.  
  34. //console.log(currentFieldValues[y].qName);
  35.  
  36. //text += currentFieldValues[y].qName + " ";
  37.  
  38.  
  39.  
  40.  
  41.  
  42. text += "<span class='label " + labeltype + "'>" + currentFieldValues[y].qName + "</span> ";
  43. //put the field names into a variable
  44.  
  45. //console.log(text);
  46. }
  47.  
  48. if(i==0) {
  49. selectionslist = text;
  50. } else {
  51. selectionslist += text;
  52. }
  53.  
  54. //add the complete string for this field to an array.
  55.  
  56.  
  57.  
  58. }
  59.  
  60. console.log(selectionslist);
  61. $("#myselections").html(selectionslist);
  62.  
  63.  
  64.  
  65.  
  66. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.