Page 1 of 1

Number subform rows

Posted: Tue Jan 03, 2012 10:08 pm
by ruiascensao
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

Re: Number subform rows

Posted: Fri Jan 06, 2012 4:08 am
by admin
Rui,

Are you doing this with JavaScript when it loads or php when it saves?

Steven

Re: Number subform rows

Posted: Fri Jan 06, 2012 9:18 am
by ruiascensao
Hi Steven,

I'm doing this with JavaScript when the field Jobs_Code is getting a value.

Regards,
Rui

Re: Number subform rows

Posted: Tue Jan 10, 2012 2:30 pm
by ruiascensao
Hi Steven,

Any ideia?

Regards,
Rui

Re: Number subform rows

Posted: Tue Jan 17, 2012 7:37 am
by admin
Rui,

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

Re: Number subform rows

Posted: Tue Jan 17, 2012 4:32 pm
by ruiascensao
Thank you steven!

Regards,
Rui

Re: Number subform rows

Posted: Tue Jan 17, 2012 8:25 pm
by admin
.