Hi,
I am trying to implement this solution and am about 80% there.
I have a PO system designed with LF Forms. The user needs to be able to amend an existing PO. I need to be able to fill a table with the same data and rows as per the original PO.
As you can see below, I am able to automatically add the number of rows according to the number of options in the "Line No" field. There are 4 options, hence 4 rows in total. I am also able to automatically select each row's Line No value as per the options in the drop-down. However, the other fields to not perform their lookup. If I manually select a value from the Line No field, the Lookup works fine.
I am guessing that I need to force a trigger for the change event in order for the lookup to take place, or something along those lines.
Anyone have some idea on how to get my lookup working?
function tableUpdate() { // Don't bother unless we have data if ($('.filledField option').length < 2) { setTimeout(function () { tableUpdate(); } , 500); } else { // Get the number of <option> tags in filledField (q11) -1 because there's a blank option var resultNumber = $('.filledField option').size() - 1; // Get all the rows of the table var tableRows = $('#q4 table tr'); // Determine whether we need to add or subtract rows (-1 for the header row) var rowDelta = 0; rowDelta = resultNumber - (tableRows.size() - 1); alert(resultNumber + ' ' + rowDelta + ' ' + tableRows.size()); // Add rows if(rowDelta > 0) { // Click the Add link that number of times repeatXTimes(rowDelta, function() { $('#q5').click(); }); // Subtract rows } else if(rowDelta <= 0) { // Find the delete buttons, do the following with eacH $("#q4 span.form-del-field").each(function(id, del_btn) { // id = row number (excluding header, starting at 0), del_btn = the delete button // If the row number (id) is more than we should have if(id >= resultNumber-1) { // Click the delete button alert('Deleting Row ' + id + ' ' + ' ' + resultNumber); $(del_btn).click(); } }); } // Do the following for each option in filledField (q11) $('.filledField option').each(function(oid,opt) { // oid = the option line number, opt = the actual <option> element for (var i = 1; i <= resultNumber; i++) { var k = i + 1; $('td.filledColumn select').eq(i-1).val($('.filledField option:nth-child(' + k + ')').text()); $('td.filledColumn').eq(i-1).trigger('lookup'); } }); } }