How to create two dimensional array in jquery or js
Posted
by
learner
on Stack Overflow
See other posts from Stack Overflow
or by learner
Published on 2012-06-04T10:37:33Z
Indexed on
2012/06/04
10:40 UTC
Read the original article
Hit count: 220
I need to create dynamic global two dimensional array in jquery or javascript
My function is like this
<script>
var index = 0;
var globalArray = new Array();
function createArray(){
var loop = globalArray[index].length;
var name = $.("#uname").val();
if(loop == 0){
globalArray[index][0] = uname;
}else{
globalArray[index][loop++] = uname;
}
}
</script>
<div><input type="text" id="uname"> <input type='button' value='save' onclick='createArray();'> </div>
On click of that button I am getting this error "globalArray[index] is undefined"
How can I create one global array using jquery or javascript like this.
I dont want any hidden field and all.
Please help me.
Thanks
© Stack Overflow or respective owner