Hi Gurus, I am trying to use 2 dimensional array in javascript for storing strings. But I am not able to get the values correctly. Below is my code.
var commentstore=new Array();
function creating(id,day)
{
if(commentstore[day,id] != null)
{
alert("It already exists: commentstore["+day+"]["+id+"]"+commentstore[day,id] );
var textinput="<div id='closeit'>Comments:<input type='text' name='comm["+day+"] ["+id+"]' value='"+commentstore[day,id]+"'/></div>
<div id='closing' onclick='closecomment("+id+","+day+")'>:)</div>";
}
else
{
var textinput="<div id='closeit'>Comments:<input type='text' name='comm["+day+"] ["+id+"]' /></div>
<div id='closing' onclick='closecomment("+id+","+day+")'>:)</div>";
$('#comm').html(textinput);
}
function closecomment(id,day)
{
comm.style.visibility='hidden';
var str='comm['+day+']['+id+']';
var element = document.getElementById(str);
if(element.value !=null)
{
commentstore[day,id]=element.value;
alert('New values stored: commentstore['+day+']['+id+']'+commentstore[day,id]);
}
}
So in the above code if commentstore[0,0]='man' then commentstore[1,0] and [2,0] and [3,0] ....[7,0] are also filled with 'man'. Same thing is happening with commentstore[0,1] even commentstore[4,1] scenarios. Can any one please provide any tutorial or sample code where we can dynamically create javascript 2d arrays. Thanks in advance.