| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 49060 | 2004-09-09 05:08:00 | Javascript Help: Arrays | willie_M (5608) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 270617 | 2004-09-09 05:08:00 | Hey guys. I'm stuck on a javascript problem again. Here tis <script language ="javascript"> function initialize(A,Name,Phone,Gender,Age,School) { var A=new Array(); A[0] = Name; A[1] = Phone; A[2] = Gender; A[3] = Age; A[4] = School; } var amate, amate1, amate2 initialize(amate,"Nick","4288666","M","18","Employed"); initialize(amate1,"Feral","4285593","M","18","Employed"); initialize(amate2,"Dirty","4283184","M","17","Employed"); document.write("<table><th>Name</th><th>Phone</th><th>Gender</th><th>Age</th><th>School</th><tr>"); for(var i=0; i<5; i++) { document.write("<td>"+amate[i]+"</td>"); } document.write("</tr>"); for(var i=0; i<5; i++) { document.write("<td>"+amate1[i]+"</td>"); } document.write("</tr>"); for(var i=0; i<5; i++) { document.write("<td>"+amate2[i]+"</td>"); } document.write("</tr></table>"); document.write(" The number of elements in the array is "+amate.length); </script> The problem is, it throws an error saying amate is not an object line 25 char 3 (first for loop). What have i done wrong? |
willie_M (5608) | ||
| 270618 | 2004-09-09 05:12:00 | Does it need a semicolon after you declared the variables | Rob99 (151) | ||
| 270619 | 2004-09-09 06:31:00 | It appeas to be how the array is filled and displayed. My previous suggestion probally will make no difference. Do you have to use initialize to fill the arrays? Or are you allowd to do it another way. | Rob99 (151) | ||
| 270620 | 2004-09-09 06:41:00 | I agree with you Rob - I don't think the arrays need to be initialised. just a amate = ("whatever1","whatever2",etc) would do the trick. |
antmannz (28) | ||
| 270621 | 2004-09-09 10:48:00 | >I agree with you Rob - I don't think the arrays need to be initialised. >just a > amate = ("whatever1","whatever2",etc) >would do the trick. What? I have to use the initialize function to define the parameters... |
willie_M (5608) | ||
| 1 | |||||