ahesan429
08-31-2010, 07:06 AM
I want to pass dynamic array values to java script function.how its possible. explain with some code.........
|
||||
Passing Dyanmic Array values to Javascript Functionahesan429 08-31-2010, 07:06 AM I want to pass dynamic array values to java script function.how its possible. explain with some code......... Old Pedant 08-31-2010, 07:19 AM ??? same way you pass any array. The question is: Where is the "dynamic array" coming from? What are the elements of the array? Is the array homogeneous or heterogeneous? Is it an associative array or a numbered array? But, really, all those questions would apply to a static array as well as a dynamic one. Is this homework? ahesan429 08-31-2010, 01:04 PM ??? same way you pass any array. The question is: Where is the "dynamic array" coming from? What are the elements of the array? Is the array homogeneous or heterogeneous? Is it an associative array or a numbered array? But, really, all those questions would apply to a static array as well as a dynamic one. Is this homework? how to pass static array that i dont know can you tell me with code.... Old Pedant 08-31-2010, 07:22 PM var names = [ "Adam", "Bob", "Cherry", "Dana" ]; var cities = ["Atlanta", "Boston", "Chicago" ]; function reverseArray( ar ) { var reverse = []; for ( var ix = ar.length-1; ix >= 0; --ix ) { reverse.push( ar[ix] ); } return reverse; } alert( names ); alert( reverseArray(names) ); alert( cities ); alert( reverseArray(cities) ); rnd me 08-31-2010, 10:47 PM var names = [ "Adam", "Bob", "Cherry", "Dana" ]; var cities = ["Atlanta", "Boston", "Chicago" ]; function reverseArray( ar ) { var reverse = []; for ( var ix = ar.length-1; ix >= 0; --ix ) { reverse.push( ar[ix] ); } return reverse; } alert( names ); alert( reverseArray(names) ); alert( cities ); alert( reverseArray(cities) ); what's with that function? function reverseArray( ar ){ return ar.concat().reverse(); } Old Pedant 08-31-2010, 11:00 PM Yes, yes, I know. But he wanted a DEMONSTRATION of accessing an array, so I wanted to show visiting all the elements. Reversing was the simplest thing I could think of. <grin/> rnd me 09-01-2010, 08:09 PM Yes, yes, I know. But he wanted a DEMONSTRATION of accessing an array, so I wanted to show visiting all the elements. Reversing was the simplest thing I could think of. <grin/> touchè; i just worry about noobs copy and pasting this wonderful working reverse function into some page i have to wait for... ;) |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum