views:

1629

answers:

1

May i know whats wrong inside this.I am new world of programing ..So if you help me it would be wonderful.The error comes on the line

arr[${i.count-1}][1]=${employee.email};

Awaiting for your response.The entire Code as follows..

$(function() {
var arr = new Array();

   arr[0]=new Array(4);
   arr[0][0]=sathis;
   arr[0][1][email protected];
   arr[0][2]=namakkal;
   arr[0][3]=21;

   arr[1]=new Array(4);
   arr[1][0]=ganesh;
   arr[1][1][email protected];
   arr[1][2]=karaikudi;
   arr[1][3]=22;

   arr[2]=new Array(4);
   arr[2][0]=karthik;
   arr[2][1][email protected];
   arr[2][2]=trichy;
   arr[2][3]=25;

 var str="<table><tr><th>Name</th><th>Email</th><th>City</th><th>Age</th></tr><tr><td>";

 $("#emp_name").change(function() {
     var i=$(this).val();
    str=str+arr[i-1][0]+"</td><td>"+arr[i-1][1]+"</td><td>"+arr[i-1][2]+"</td><td>"+arr[i-1][3]+"</td><tr></table>";
    $("#viewer").html(str);
    alert(str);
    });


});
+3  A: 

Ummm... you need quotes for strings. For example, you need arr[0][0]='sathis'; instead of arr[0][0]=sathis;

Also, there's an easier way to do arrays:

arr[0] = ['sathis', '[email protected]', 'namakkal', 21];