• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 61
  • Last Modified:

Javascript Loop Issue

Using NodeJS.oracle, hence the use of javascript for my loop, but can't use jquery....
I have a record set from an Oracle query that returns twenty columns, one of which is "ticket".
I need to loop thru the results, and for every 30 records, push the value of "ticket" into a separate array. So I would end up with:
ticketArray1 = '1', '2', '3', ...... '30'
ticketArray2 = '31', '32', '33' ..... '60'
ticketArray3......

so I loop thru the query results and pus the results into a mainArray, that works fine

then I need to loop thru the mianArray and populate the ticket arrays. I can figure out how to get the value from the first 30 but I'm lost on getting values thereafter and populating separate arrays.
Thanks in advance for any assistance.
0
kevbob650
Asked:
kevbob650
  • 4
  • 4
  • 2
1 Solution
 
Phil PhillipsDirector of DevOps & Quality AssuranceCommented:
I think I know what you're getting at, but I'm not 100% sure.  Could you post what you have so far for the first 30?  I should be able to build off of that.
0
 
Tom BeckCommented:
Here's a fiddle that divides an array of 100 items into groups of 30.

http://jsfiddle.net/tommyBoy/nwtbwxrz/
0
 
kevbob650Author Commented:
Still confused, this is what I have, but getting an error saying "arrTicketList[arrTicketList.length] is not defined"
This is the result set of an Oracle query, 20 columns, I need column 4 for example.  See attached code example, I wasn't able to show code with braced "i" values??
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Phil PhillipsDirector of DevOps & Quality AssuranceCommented:
Looks like your code didn't attach.

Though, "arrTicketList[arrTicketList.length]" won't work because arrays start at 0.  So, the last element of an array would be at "arrTicketList.length - 1"
0
 
kevbob650Author Commented:
Let me try the attachment again, not sure what happened, never attached a file before but it wouldn't let me submit the file since it had brackets with an iterator, go figure.
code-example.txt
0
 
Tom BeckCommented:
I updated my jsFiddle to include a multidimensional array with twenty columns (represents your Oracle return). I extract the fourth column value into groups of five. I used your variable names where appropriate.

http://jsfiddle.net/jg17b533/5/
0
 
kevbob650Author Commented:
Thanks TomBeck,
We're getting closer!  So what your code does is uses a list but I need to create a series of arrays that I can loop thru on further steps  I will loop thru each new array and call a nodeJs function for each value(scary). Hence I was trying to develop a series of arrays like:
arrTicketList[0] = ['tkt1',' tk2',' tk3'. , etc...]
arrTicketList[1] = ['tkt1',' tk2',' tk3'. , etc...]
arrTicketList[2] = ['tkt1',' tk2',' tk3'. , etc...]
etc..
But I also tried using the 'i' value but I get the same error, arrTicketList is not defined?
0
 
Tom BeckCommented:
Left the <UL> in place and added in the arrTicketList array of arrays.

http://jsfiddle.net/jg17b533/6/
0
 
kevbob650Author Commented:
Thanks for all of the posts, very helpful
0
 
Tom BeckCommented:
You're welcome. Thanks for the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now