Copying Values using JQuery

This is a nice way to copy Apex Item values using JQuery. The trick is using a parameter as an attribute name in the JQuery seletor.

function copyField(FieldFrom,FieldTo) {
// loop through items
$('input[name='+FieldTo+']').each(function(index) {
var rownum = $(this).attr('id').substr(3,5);
var FromVal = $v(FieldFrom+$(this).attr('id').substr(3,5))
$(this).val(FromVal);
});
}

This requires a 4 digit rownum to be appended to the item name in the sql to produce a unique id; e.g. name = "f01" and id = "f01_0001".

Comments