1

So basically I have a list of links that I want the user to see through a popup of some sort. I found a similar question here that the solution was to make an UI panel to do this. But it was for only one link. I need to put in multiple links in the same area one after the other. When I tried this for multiple links, it displayed an error that said only one child per parent is allowed or something of the sort.

I hope someone can push me in the right direction. And is it actually not possible to put in a hyperlink in a message box or a toast..?

Thanks in advance.

Community
  • 1
  • 1
PhysLabTsar
  • 256
  • 2
  • 5
  • 11
  • With the right type of panel, you can add multiple links. Can you post your code here. Also try using a different panel, a VerticalPanel perhaps – Srik Jul 09 '13 at 08:22
  • I would be only posting a slight variation of the code from the link I posted above. But you and Serge answered my question. Thanks! – PhysLabTsar Jul 09 '13 at 20:31

1 Answers1

1

As Srik commented, use a different panel like this for example :

function test(){
showURL('Google','http://www.google.com','Stackoverflow','http://stackoverflow.com/questions/tagged/google-apps-script')
}

function showURL(name1,href1,name2,href2){ // for ease of use I give the urls as parameters but you could define these urls in the function as well
  var app = UiApp.createApplication().setHeight(60).setWidth(200);
  app.setTitle("Show URLs");
  var link1 = app.createAnchor(name1, href1);
  var link2 = app.createAnchor(name2, href2);

  app.add(app.createVerticalPanel().add(link1).add(link2));  // add others as needed
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
  }

enter image description here


EDIT : thanks for accepting - if you need it to be dynamic try something like this, using an array as argument :

function test(){
showURL(['Google','http://www.google.com','Stackoverflow','http://stackoverflow.com/questions/tagged/google-apps-script','Google','http://www.google.com','Stackoverflow','http://stackoverflow.com/questions/tagged/google-apps-script'])
}

function showURL(data){ // for ease of use I give the urls as parameters but you could define these urls in the function as well
  var app = UiApp.createApplication().setHeight(40+8*data.length).setWidth(200);
  app.setTitle("Show URLs");
  var panel = app.createVerticalPanel();
  app.add(panel);
  for(var d=0 ; d<data.length;d=d+2){
  var link = app.createAnchor(data[d], data[(d+1)]);
  panel.add(link);
  }
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
  }
Serge insas
  • 45,904
  • 7
  • 105
  • 131
  • Thank you Serge! This pushed me in the right direction. I have a dynamic list of links but using your code above it will not be hard to implement at all. I just needed something like this to run with. Thank you so much! – PhysLabTsar Jul 09 '13 at 19:35
  • I had started to tweak your original code to work with a dynamic list. But your new code is much more efficient than mine. Thanks! :) – PhysLabTsar Jul 09 '13 at 20:37
  • My pleasure :-) , there are many ways to get this to work..., using arrays is probably one of the easiest. Objects would have been nice too... – Serge insas Jul 09 '13 at 20:51