Thank you for this solution - I great solution to get your Links on the catalog form since there is no URL Catalog variable type available.


wiltonr
Giga Contributor

Do you know how I can pass a url to a ui macro so that it will display on my catalog item in this manner:



I am building a url on change of a variable on my catalog item but a client script making an ajax call to a table with some specific values.   So I return a url that is similar to this:



https://xxxxxxxx.wustl.edu/docid=1234&invid=65434&docdept=65434



I want this to then display on my catalog item more like this:



Click here to View Image



I am thinking I need to use a UI Macro variable.   i am able to pass the url to the ui macro but I can't figure out how to then get the code in the ui macro to be able to insert it into the <a href tag.



Any help would be appreciated.


Hi Rhonda,



Suppose u are having url in a variable called url then u just need to build HTML String as follow



var url = 'https://google.com' ;         //get it using ajax


var text   = '<a target="_blank" href="'+url+'">Here</a>' ;


//then use the same function (setDesc) to set above html in the macro



setDesc(text) ;


In this case, then what does the UI macro code look like?


Below should be the code in UI Macro



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<div id="short_description"/>


  <script>


  function setDesc(text){


  document.getElementById('short_description').innerHTML = text;


  }


    </script>


</j:jelly>





Now in onChange client script use the same code as provided in previous reply.