File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Arrays in JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Arrays in JavaScript" Watch "Arrays in JavaScript" New topic
Author

Arrays in JavaScript

Madhav Kanneganti
Greenhorn

Joined: Jan 20, 2012
Posts: 25
Hi, I'm wonder to know how to build an array just like the following dynamically. i.e. Im doing a multi columns sorting and from the child window after we selected multiple columns with their order the results should be populated like this.

I was building like this
Here rowCount is number of columns that we selected from the table and resArray is an array.
Is this right way Im building?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61447
    
  67

Rather than using arrays in arrays, I'd make each array element an object with two properties rather than a 2-element array. Makes everything much neater and easier to understand.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Madhav Kanneganti
Greenhorn

Joined: Jan 20, 2012
Posts: 25
Hi Bear,

I'm using jquery table sorter api to do multi columns sorting and this api needs the array like this, hence I was requesting how to build dynamically. Would your suggestion applicable to my request?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61447
    
  67

You should have explained that to begin with. If that's what the plugin needs, you can't change it.

What specific problems are you having?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
FYI: In HTML4, ids really should not begin with a number. Some browsers have issues with that.

Also the selector $("input:radio[id="+i+"_order]:checked") is a waste. You are making it slower, just select the id!

Personally I would do something more like



>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays in JavaScript