Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

nuSubformRowArray()

Post Reply
ricklincs
Posts: 107
Joined: Mon Aug 01, 2011 5:39 pm
Has thanked: 33 times

nuSubformRowArray()

Unread post 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.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuSubformRowArray()

Unread post by admin »

ricklincs,

Is receipt_id a number field or a varchar?

Steven
Post Reply