Y = New Array()

free web hosting
Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > Client Side Scripting > Javascript

Y = New Array()

al-rafideen
Hi,
I have no problem with one dimension Array. For example:
Y = new Array();
Y[0] = smith;
Y[1] = john;
..
..

My problem is with two dimension Array. For example:
Y[0,0] = smith;
Y[0,1] = john;
..
..
Do you agree to define Y = new Array() with two dimension Array.
Thank you for your help in this matter.

Reply

Jeigh
As far as I know (I may be wrong, I don't do a lot of javascript work) there are not true 2d arrays in javascript. You can, however, declare one array and then declare elements within that array as arrays which in effect is a multi-dimensional array. The site at http://www.javascriptkit.com/javatutors/twoarray1.shtml can show you an example and I found a bunch more just by quickly googling for '2d arrays in javascript'. It will likely take some playing around but if its important to your design I'm sure you can get something working that will be equivalent to having a 2 dimensional array.

Reply

kelvinmaki
Actually declare Y = new Array() is for the top level of the array, not a 2D array. So afterwhich you've declared that, you need to declare another array inside of Y. So like,

Y = new Array();
Y[0] = new Array();
Y[1] = new Array();

Then you are allow to put data into Y[0] array. eg.

Y[0][0] = smith;
Y[0][1] = smith2;
Y[1][0] = john;
Y[1][1] = john2;

Now then you'll have a 2D array. I've gotten error not declaring new Array() for both cases. Hope this help. Cheers

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. how to connect the database throught the javascript in confirm box - 179.60 hr back. (1)
Similar Topics

Keywords : y, array,

  1. OSCommerce Errors
    Passed variable is not an array or object (5)
  2. Day_sort()
    Sort an array by day (1)
    If it wasn't for vujsa and HandyPHP.com , or the discussion over at Trap17.com . I would
    have had no reason to make this function more flexible and act more like a PHP function. So this is
    why I have done this, though I would have contributed it to Trap17.com , I was not a member over
    there nor does it benefit me in anyway. None of the code has been taken from HandyPHP.com .
    It's a complete rewrite in a way I felt works better for most people, it could do with better
    error handling though, but that can be discussed here if needs be. So here it is: day....
  3. Raid 1 Array
    question... (6)
    I want to implement a RAID 1 array in my computer with 2 80 GB drives. However, after reading a bit,
    (maybe the wrong stuff) I ended up at the point that Windows XP Professional does not support
    mirroring. I'm not interested in the other forms of RAID to increase performance. with the power
    outages all the time my primary concern is backing up the data. So is it true that mirroring is not
    available with XP Pro?....
  4. Passing Select List As An Assoc. Array
    (1)
    I'm trying to pass a select list as an associative array, but evertime I do this the $key
    becomes numbered from 0 up like a normal array. I have an onchange on a select list that
    generates an addbox. The currentbox is loaded the first time the page is loaded by pulling from the
    database. I want to only pull that one time, and each time the select list generates new results
    for the add box, I want the data inside of the current box to be sent to itself. Here's a
    diagram of the layout: As you can see the arrows indicate that the items are to be move....
  5. Array Of <divs> In Another <div> Tag
    (2)
    I have a tag with id="foo" containing numerous tags in it. Throught the course of my script, I
    need to make some of the int foo hidden and some visible. To this end, I was wondering if there
    is some way to create or get an array of the various tags in foo. ~Viz....
  6. MySQL: Help Needed With MySQL_fetch_array() Error
    help needed (7)
    I have my site up and running, it it written in php but the problem im getting is the mysql database
    the warning is: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
    resource in /home/mrogers/public_html/config.php on line 47 but on line 47 it shows this:
    $email = mysql_fetch_array($adminemail); any one help on this + my site wont connect to
    my database. I have feeled out all the requirements that has asked and i know its write. All help
    would be apreciated as i would like my site fully functional by next week. /smile.gif' bord....
  7. Help Needed With MySQL_fetch-array() Error
    (3)
    databasing is quiet hard to learn but im starting to get the hang of it. on my home page i have a
    few errors like this Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
    resource in /home/mrogers/public_html/html/nav.php on line 80 i have checked whats on line 80 and
    this is what i ended up with $row = mysql_fetch_array($sql); but it does not look like
    anything is wrong and i kind of do not under stand the mysql witch i am learning at the moment, but
    any one know what the problem is please tell me. need any more info like the whol....
  8. [visual Basic] How To Confirm A Array Is Null
    (6)
    for example, Dim array() as integer during run time, how to confirm a array is null (do not
    contain any element) Thanks....
  9. Array Sorting
    Does anyone hava a decent JAVA method (21)
    does anyone have a decent JAVA method that will sort an array from smallest-to highest?
    /mellow.gif" style="vertical-align:middle" emoid=":mellow:" border="0" alt="mellow.gif" /> The one
    i'm trying to write doesn't seem to work... or if you could look at mine below, and tell me
    what i did wrong, that'd be nice to.(if it reallllyyyyyyyyy sucks, please dont laugh to loud
    /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> ) This should
    take an array and then calculate how many of a number is in it, add it to the first slots....
  10. Convert a byte array to an int and vice versa
    (2)
    Due to a horrible file i/o system I have to use at work (reads in a file and returns an array of
    bytes), I needed to write a conversion scheme for making these bytes into ints and back again.
    I'll post it up here for you guys. Note: this only handles the PC's little endian-ness.
    uint32 GetInt32( uint8 *pBytes ) { return (uint32)(*(pBytes + 3) } void Int32ToUInt8Arr( int32
    val, uint8 *pBytes ) { pBytes = (uint8)val; pBytes = (uint8)(val >> 8); pBytes = (uint8)(val
    >> 16); pBytes = (uint8)(val >> 24); }....

    1. Looking for y, array,

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for y, array,
advertisement




Y = New Array()



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE