All Array is not returning [Coding Error]
Hii Everybody,
Anyone help me to sort out the problem.
Actually i have a table with input box (a1,b1,c1,d1)(a2,b2,c2,d2)etc
When user Click the button i want to copy those input values into multidimensional array.so that
mainarray[0] can contains array of elements (a1,b1,c1,d1)
My problem is that why CopyInputs() function not returning more array
After executing for (a1,b1,c1,d1) its not returning for others
Since I am new to javascript ,Awaiting for your solutions
<script>
var mainarray=new Array()
var excelArray=new Array("a","b","c","d","xyz")
function RowCopy()
{
totalnoofrows=3
for(i=0;i<=totalnoofrows;i++)
{
//copy the rows
mainarray[i]=CopyInputs(i)
}
alert(mainarray[0][2]) //OK
// alert(mainarray[1][2]) //Error Why not copy row(a2,b2,c2,d2)??
}
function CopyInputs(whichrow)
{
curr_rowSelected="1,3,4"
arr1=curr_rowSelected.split(',')
actual_row=arr1[whichrow]
var temp=new Array();
for(i=0;i<=3;i++)
{
currrow=excelArray[i]+actual_row
//alert("i="+i+"curr_row="+currrow);
obj=document.getElementById(currrow)
temp[i]=obj.value
}
return temp
}
</script>
<input type=button value="getrows" name=clk onclick="RowCopy()">
<table border=1>
<tr><td><input type=text id="a1">
</td><td><input type=text id="b1">
</td><td><input type=text id="c1">
</td><td><input type=text id="d1"></td>
</tr>
<tr><td><input type=text id="a2">
</td><td><input type=text id="b2">
</td><td><input type=text id="c2">
</td><td><input type=text id="d2"></td>
</tr>
<tr><td><input type=text id="a3">
</td><td><input type=text id="b3">
</td><td><input type=text id="c3">
</td><td><input type=text id="d3"></td>
</tr>
<tr><td><input type=text id="a4">
</td><td><input type=text id="b4">
</td><td><input type=text id="c4">
</td><td><input type=text id="d4"></td>
</tr>
</table>
Cheers :)
vinod
__________________
Cheers :)
vinod
|