Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

HELP with Row

Post Reply
at_rcc
Posts: 32
Joined: Thu Sep 02, 2010 11:19 am

HELP with Row

Unread post 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
admin
Site Admin
Posts: 2782
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 2 times

Re: HELP with Row

Unread post 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
Post Reply