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

Question

Question

Copy row value

asked on May 29, 2016 Show version history

Hi,

I need some assistance here, I am copying some values from the above row to the added row using the following script example

$(document).on('click', '.cf-table-add-row', function(){
$('.datefield input').last().val($('.datefield input:eq(-2)').val());
$('.rate select').last().val($('.rate selecteq(-2)').val());
 });

It works well when creating a table from the beginning. The issue comes when adding a table row after downloading values into the table via lookup. On the first added row instead of copying the value of the upper row, it just inputs a number. But the moment you fill in this first added row, the subsequent rows are ok. What might be causing this? 

Mrk

Untitled.png
Untitled.png (7.9 KB)
0 0

Answer

SELECTED ANSWER
replied on May 29, 2016 Show version history

Hi Mark,

When filling table rows by lookup, a hidden input element is generated for each row. If you check the html elements you could see two input elements together, and the hidden one has name like "PopulatedField."

The suggestion is adding ":visible" selector as $('.datefield input').last().val($('.datefield input:visible:eq(-2)').val());

1 0
replied on May 30, 2016

Thanks Rui,  it worked perfectly

Mark

0 0

Replies

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

Sign in to reply to this post.