Page 1 of 1
HELP with Row
Posted: Mon Jan 10, 2011 11:16 am
by at_rcc
Hi Every one , How to i get to automatically get each rows in a subform to have a number autogenerated in one of the fields.
i want to say that i want a receipt id to be generated uniquely automatically for each rows that exists in the sub form
Re: HELP with Row
Posted: Tue Jan 11, 2011 12:51 am
by admin
at_rcc,
you can put this code in the JavaScript section of the form which has the subform.
Code: Select all
function nuLoadThis(){
var subformToPopulate = 'receipt_subform'; //---- the name of the subform
var fieldToPopulate = 'receipt_id'; //---- the name of the field to populate
var lastNumberFrom = 100;
var theList = nuSubformRowArray(subformToPopulate);
for (var i = 0 ; i < theList.length ; i++){
var fieldInRow = document.getElementById(theList[i] + fieldToPopulate);
if(fieldInRow.value == ''){
fieldInRow.value = lastNumberFrom;
lastNumberFrom = lastNumberFrom + 1;
}else{
lastNumberFrom = Number(fieldInRow.value) + 1;
}
}
}
nuLoadThis() will be run automatically as the Form loads.
nuSubformRowArray() is a nuBuilder function that returns an array of each row's prefix.
regards
Steven