Results 1 to 2 of 2
  1. #1
    New Member
    Join Date
    May 2007
    Location
    North Carolina
    Posts
    1

    Totally Confusing Javascript Error

    I am trying to use javascript to load select menus and other elements of page to make the use of the page faster.

    I am in the middle of my project and am the type of person that will go crazy before moving on to a different part of my project.

    Here is my problem... I want to write a javascript link to a table in my page, if I use text in the link the javascript works perfectly, however, if I use a variable ( because the javascript cycles through all my data ) the javascript won't run the next javascript function I need it to run.

    Here is the function I am using...

    function RenderServiceListing( CompanyList )
    {
    var ServiceCheck
    var ListingTable
    var NewBody = 0

    ListingTable = "<TABLE width = '365' border = '1' cellpadding = '0' cellspacing = '0'>";
    for ( a = 0; a < CompanyList.length; a++ )
    {
    ListingTable+="<TR><TD width = '365' align = 'left' valign = 'top'>"
    ArgOne = "tbl"+CompanyList[a]
    ArgTwo = "img"+CompanyList[a]
    ArgThr = "link"+CompanyList[a]

    ListingTable+="<a href='javascript:toggle("+ArgOne+","+ArgTwo+")'>"
    ListingTable+= "<img src = 'images/arrow_down.gif' border = '0' id = "+ArgTwo+"></a>"

    ListingTable += "<a href='javascript:toggleme("+CompanyList[a]+")'>"+CompanyList[a]+"</a>"

    // Here is the line of code that is giving me trouble, the line above is where I am trying to write to my web page, the link gets written to the page and the javascript shows up in my status bar but when I click the link the new function "ToggleMe" doesn't load.

    // Right now toggleme() just has an alert to see if I get there or not. See the function toggleme() below

    ListingTable+="</TD></TR>";
    ServiceCheck = CompanyList[a]

    ListingTable+="<tbody id = "+ArgOne+">"

    while ( ServiceCheck == CompanyList[a] )
    {
    a = a + 2
    ListingTable+="<TR><TD width = '365' align = 'left' valign = 'top'>"+CompanyList[a]+"</TD>"
    ListingTable+="</TR>";
    a++
    }
    a = a - 1
    ListingTable+="</tbody>"
    }
    ListingTable+="</TABLE>";
    document.getElementById('PostList').innerHTML = ListingTable
    }

    function toggleme( TestName )
    {
    alert ( "Test Name is: "+TestName)
    }

  2. #2
    try it with a dummy variable and see if it works if it does then u know there is something up with the current variable
    u can also try the function call without the javascript: it probably wont help but u never know

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Subscribe to us on YouTube