How to insert multiple URL's in a single field?

User150433
Tera Guru

Hello All,

I have a requirement where we have to provide multiple links in a single field.User should have the freedom of clicking on any link and opening in a new tab/window.Currently in out of box functionality of SNC,they have provided a URL field which works as single link and not multiple.

Can someone please provide some assistance on this?

Thanks.

10 REPLIES 10

Is that a URL or HTML field ?


HTML


-Anurag

sergioap
Kilo Contributor

If you want to avoid using an HTML field you can do it in two ways:


- First one is by having a choice field with different choices (and its values the url) and a UIA that popups the value of the choice field.



- The other one is by DOM manipulation, onLoad script, the code is a bit shoddy but works for me:


-------------------------------------------------------------------------------------------------------------------


var originalOuterHtml;


var counter = 0;


var links;


var originalId;




function onLoad() {



  var varname = 'u_testing'; // This is the only thing you need to change - field name



  var el = g_form.getElement(varname);


  originalOuterHtml = el.outerHTML;


  originalId = el.id;


  links = g_form.getValue(varname).split("\n")



  changeLabelClickEvent(varname);


}




function changeLabelClickEvent(varname){


  var label = g_form.getLabel(varname);



  var pattern = /onclick="(.*);"/;


  var found = pattern.exec(label.outerHTML);



  if(found[0]){


  var newOnclick = "onclick=\"return changeElementType('"+varname+"');\"";


  label.outerHTML = label.outerHTML.replace(found[0],newOnclick);


  }


}




function changeElementType(varname){



  var pair = counter % 2;


  var el = document.getElementById(originalId);


  counter++;



  if(pair == 0){


  var newOuterHtml = "<div id='"+originalId+"'>";



  for(var i=0; i<links.length; i++){


  newOuterHtml += '<a href="'+links[i]+'">'+links[i]+'</a><br>';


  }


  newOuterHtml += "</div>";



  el.outerHTML = newOuterHtml;


  }else{


  el.outerHTML = originalOuterHtml;


  changeLabelClickEvent(varname);


  }


}


-------------------------------------------------------------------------------------------------------------------


How it works? you have a textarea field called 'u_testing' (in my example) and there you write your urls. By clicking on the field label the field will change into the urls you wrote on the textArea. By click label again it will change back to the original textArea field allowing you to modify the urls.



Regards,


gomsi
Kilo Contributor

Hi Sergioap,



I tried seems all cool but i got stuck in one place when i am putting all url and saving the form then its considering all url as a single url .



Can you suggest , how they will be appear as a separate URL ?


I am facing the same issue. Did you find solution for it?