Page 1 of 1

nuSubformRowArray()

Posted: Tue Nov 01, 2011 11:29 am
by ricklincs
I have used the following JavaScript code from a previous post to add a line number into a subform.


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 + fieldToPopulate);

if(fieldInRow.value == ''){
fieldInRow.value = lastNumberFrom;
lastNumberFrom = lastNumberFrom + 1;
}else{
lastNumberFrom = Number(fieldInRow.value) + 1;
}

}

}

This works well, but if I have more than 9 lines on the subform it puts the lines in the wrong order ie Line 1,11,12,13,14,2,3,4,5,6,7,8,9 does anybody know of the correct place to put an array sort. As always thanks for the help.

Re: nuSubformRowArray()

Posted: Thu Nov 03, 2011 11:09 pm
by admin
ricklincs,

Is receipt_id a number field or a varchar?

Steven