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!
Please register and login to view forums and other content only available to registered users.
Please register and login to view forums and other content only available to registered users.
HELP with Row
-
- Site Admin
- Posts: 2782
- Joined: Mon Jun 15, 2009 2:23 am
- nuBuilder Version: 4.5
- Been thanked: 2 times
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