Hi,
I´m using a subform with a field(jobs_num) that is the row number +1(because the subform rows begins with 0). The problem is when the user deletes a row. For example if the form has 6 rows, when I delete row 2 and add a new one, the Jobs_num of that row will be 6 again.
How can I solve this problem?
Thanks!
Regards,
Rui
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.
Number subform rows
-
- Site Admin
- Posts: 2786
- Joined: Mon Jun 15, 2009 2:23 am
- nuBuilder Version: 4.5
- Been thanked: 3 times
Re: Number subform rows
Rui,
Are you doing this with JavaScript when it loads or php when it saves?
Steven
Are you doing this with JavaScript when it loads or php when it saves?
Steven
-
- Posts: 177
- Joined: Tue Nov 15, 2011 2:24 pm
Re: Number subform rows
Hi Steven,
I'm doing this with JavaScript when the field Jobs_Code is getting a value.
Regards,
Rui
I'm doing this with JavaScript when the field Jobs_Code is getting a value.
Regards,
Rui
BR
Rui
Rui
-
- Posts: 177
- Joined: Tue Nov 15, 2011 2:24 pm
-
- Site Admin
- Posts: 2786
- Joined: Mon Jun 15, 2009 2:23 am
- nuBuilder Version: 4.5
- Been thanked: 3 times
Re: Number subform rows
Rui,
Use this to get the next number..
Steven
Use this to get the next number..
Code: Select all
function getNextNo(){
var theSubform = 'receipt_subform'; //---- the name of the subform
var theField = 'receipt_id'; //---- the name of the fields with the generated number
var biggestNo = Number(0);
var theList = nuSubformRowArray(theSubform);
for (var i = 0 ; i < theList.length ; i++){
var thisNo = Number(document.getElementById(theList[i] + theField).value);
biggestNo = math.Max(biggestNo, thisNo);
}
return Number(biggestNo) + 1;
}
Steven
-
- Posts: 177
- Joined: Tue Nov 15, 2011 2:24 pm