Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Arrays??

Status
Not open for further replies.

venomdesign

Programmer
Apr 6, 2001
18
0
0
US
Is there a way to create dynamic arrays using javascript or anything else? I need to pull information from a database with JSP but I need to be able to create the arrays dynamically so the page doesn't need to be reload.
 
When you say create them dynamically, do you mean you might need maybe one array or maybe three arrays, or do you mean you might need one element or maybe three elements??

If you don't know how many arrays you need, then you just write the client side code out with your JSP pages... I have no experience specifically with JSP, but with asp, you just use the response.write method to write out client side code...

I'm assuming in JSP, it's document.write...

If you just need to add elements on the fly, that's no problem either...

As jaredn so astutely pointed out in an earlier post, you don't have to declare how many elements you want in an array in javascript --

and if you need to put one on the back of the array, just use this

myArray[myArray.length] = whatever

because the array is 0 based, that puts another element right on the back of the array, and because you didn't specify how big you wanted the array, it just makes itself bigger.... sort of like vectors... only it just increases itself by 1 when it needs to rather than by 50%.

good luck! :)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top