Hello. We are pulling a url from a sql table into a forms table using a lookup rule. The url is clickable using javascript. We are trying to change the visible portion of the link with a simple quote number which is available in a 2nd column of the same table. (Normally this is hidden)
We have a single table with css class myTable. Inside are two columns with css class urlColumn and nameColumn.
The javascript allows the urlColumn value to be clickable and open. We are looking for help on adjusting the script to allow the nameColumn value to be displayed instead of the full url value. And yet, when it is clicked, it will open the url.
$(document).ready(function() {
// select all rows in the table with class "myTable"
$('.myTable').on('click','.urlColumn input',function() {
// get the value from the "nameColumn" of the current row
var name = $(this).find('.nameColumn').text();
// get the URL from the "urlColumn" of the current row
var url = $(this).find('.urlColumn').text();
// create a new anchor tag with the URL replaced by the value from the "nameColumn"
var link = $('<a></a>').attr('href', name).text(name);
// replace the contents of the "urlColumn" with the new anchor tag
$(this).find('.urlColumn').html(link);
});
});