How to create two dimensional array in jquery or js
- by learner
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