View Full Version : Arrays

Dan Pick
06-24-2002, 05:30 PM
Hi all - i'm a javascript novice trying to either hide or show a load of HTML table rows - but this is difficult for me as the IDs of the table rows are in an array. The code that I've used so far is as follows, but this doesn't show and hide the rows because it doesn't involve any arrays - so this code only works when there is only one table row in the array - please help!

<SCRIPT language="javascript">
function expand(oObject) {
strID = oObject.id
strSRC= oObject.src
strTRDATA = ""

//alert (strID)
//alert (strID.slice(3))
strTRDATA = (strTRDATA.concat("tr",strID.slice(3), "Data"))
//alert (strTRDATA)

if(strSRC.search("SectionCollapse.gif") !=-1) {
else {

06-24-2002, 05:36 PM
Do you have access to the array (read/modify)? Is the table already created and you just need to hide/show different rows?

Dan Pick
06-24-2002, 05:47 PM
thanks for replying tamienne - the table is built - all of the rows have the same ID and therefore (i believe) all stored in an array - i just need to be able to manipulate the array with JS so as to hide/show the rows in the array. Thanks

06-24-2002, 07:26 PM
I'm sorry..i'm still not completely understanding what you have to work with.

What does the array and table look like?

06-24-2002, 08:39 PM

perusing on the fly, the first thing I notice is the use of concat: it wants Array arguments: that is:

anArray.concat(anotherArray, anotherArray, anotherArray)

also, it requires you to assign the main array as the object which has to be transformed, for (strangely enough) concat doesn't appear as direxctly affecting the object but... returning a NEW one! So:

anArray=anArray.concat(anotherArray, anotherArray, anotherArray)

This also means strTRDATA must be an array, not a string, and also its arguments.
this may probably solve at least one of the potential issues