Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2005, 10:10 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Function returning an array rfstuck Pro VB 6 5 March 12th, 2008 07:35 AM
Returning the Index number of an array prusila Java Basics 1 February 13th, 2007 05:54 AM
error when sorting an Array of Array nancy VBScript 2 February 17th, 2005 12:57 PM
returning error line robertdavies Classic ASP Professional 2 September 30th, 2004 09:06 AM
Returning index values from an associated array Jams30 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 October 7th, 2003 11:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.