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
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
HELP with Row
Re: HELP with Row
at_rcc,
you can put this code in the JavaScript section of the form which has the subform.
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
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