I am using an HTML field to display data (with a link) using the .innerHTML method. The data to be displayed is coming from a collection that will be populated via Lookup. For 1 result, the code works great, but it is when I have multiple results where I need help. Right now, it always takes the LAST record in the collection and what I need is for it to APPEND all the values together. See code and description below:
Existing Code:
$(document).ready(function (loadStops) {
$('.Submit').hide();
function loadStops()
{
$('.cf-collection-block ul').each(function(i)
{
$(this).each(function(e)
{
var load_id = $('.load input').val() ; //This is the load ID that will be embeded in the URL. This is NOT in the collection
var stop = i + 1;//My Stop number = iteration +1
var stopStr = $(this).find('.street input').val()
var stopCity = $(this).find('.city input').val()
var stopState = $(this).find('.state input').val()
var stopZip = $(this).find('.zip input').val()
var stopAdd = stopStr + ' ' + stopCity + ', ' + stopState + ' ' + stopZip;
var target = 'target="_blank"'; //Open link in new tab
var styleHTML = '<font size="5"> <p style="text-align: center;">'//CSS Styling of the HTML field
var link = "<a " + target + "href='https://forms.protrans.com/forms/pMKMH/?Load=" + load_id +"'>Stop #: " + stop + " " + load_id + "</a>";
document.getElementById("q3").innerHTML = styleHTML + link + "<br>" + stopAdd + "</p></font>";
});
});
}
$('.change').change(loadStops);
});
Here is the current result:
Note: When I add a second record in the collection, it automatically takes the LAST record and over-writes the existing record.
Desired Result:
Thanks,
Nate