Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Arrays

  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Arrays

    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) {
    document.all(strTRDATA).style.display="Block"
    oObject.src="/ACR.nsf/SectionExpand.gif?OpenImageResource"
    }
    else {
    document.all(strTRDATA).style.display="none"
    oObject.src="/ACR.nsf/SectionCollapse.gif?OpenImageResource"
    }
    }
    </SCRIPT>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Delaware, USA
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you have access to the array (read/modify)? Is the table already created and you just need to hide/show different rows?

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Delaware, USA
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sorry..i'm still not completely understanding what you have to work with.

    What does the array and table look like?

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    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

    ciao
    Alberto http://www.unitedscripters.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •