You are viewing limited content. For full access, please sign in.

Question

Question

single line field in table to html link

asked on January 5, 2021

Hello, 

I have a form that does a lookup and finds a Weblink URL generated via workflow. The link is showing up in the table, but it is text, not a URL link. I have set the class to link on the the field that shows the web address. When I add the script below, the field is blank. Any suggestions to getting a text field to show as a weblink? Thanks!

 

$(document).on("lookupcomplete",function(){
  $('.link [type="text"]').each(function(e,el){
   var link=$(el).val();
   $(el).replaceWith($('<a href="' + link + '" target="_blank">' + link + '</a>'));
  });
  }); 

 

0 0

Replies

replied on January 5, 2021

As a follow up. This is my full Javascript. If I put the text to html code at the top, the web address disappears. When it's at the bottom, it shows up as text and not a link. 



$(document).ready( function() {
 $('.cf-pagination-tabs li, .cf-next-btn, .cf-prev-btn').click(function(){
       $('.btn-wrapper input[type=submit]').removeClass('hidden'); 
  });
       $('.cf-pagination-tabs li').eq(0).trigger('click');
 });






$(function() {
  $(document).ready(function () {
    
   var todaysDate = new Date(); // Gets today's date
    
    // Max date attribute is in "YYYY-MM-DD".  Need to format today's date accordingly
    
    var year = todaysDate.getFullYear(); 						// YYYY
    var month = ("0" + (todaysDate.getMonth() + 1)).slice(-2);	// MM
    var day = ("0" + todaysDate.getDate()).slice(-2);			// DD

   	var minDate = (year +"-"+ month +"-"+ day); // Results in "YYYY-MM-DD" for today's date 
    
    // Now to set the max date value for the calendar to be today's date
    $('.calendarDate input').attr('max',minDate);
 
  });
});
row.find('.form-del-field').addClass("HideTableDelete");

$(document).on("lookupcomplete",function(){
  $('.link [type="text"]').each(function(e,el){
   var link=$(el).val();
   $(el).replaceWith($('<a href="' + link + '" target="_blank">' + link + '</a>'));
  });
  }); 

 

0 0
replied on January 6, 2021

It looks like you'll need to set the attributes you want explicitly on a new anchor tag. I'm not sure this will get you 100% of the way there but it's a good start:

$(document).on("lookupcomplete", function () {
    $('.link [type="text"]').each(function (e, el) {
        var link = $(el).val();
        let anchor = document.createElement('a');
        anchor.attr('href', link)
        anchor.text(link)
        $(el).replaceWith(anchor);
    });
});

https://stackoverflow.com/questions/51050728/create-html-link-using-jquery

https://stackoverflow.com/questions/1625865/replace-anchor-text-with-jquery

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.