Announcement

Collapse
No announcement yet.

Javascript dropdown error message

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Javascript dropdown error message

    I have copied and pasted the code from page 36 of the Advanced User Guide 'Creating a Drop-Down List Containing the Top-Level
    Sections and Sub Sections' into Act_Primary.html - which I have customised with my own tables, look n feel etc.

    I have inserted the code exactly as instructed - with relevant parts in the <HEAD> and <BODY> sections as outlined.

    I should point out that the menu is positioned so it appears before the BULK of the page is rendered ie. it's in the header section of each page.

    I am getting a Javascript error in the Page Preview pane, every time a page is loaded that uses Act_Primacy.html. Also, I tried Updating the site onto my local server. I get the yellow error triangle in the bottom of Internet Explorer, and the drop down menu doesn't appear at all.

    I have attached the Javascript error I'm getting; I'm also getting another JS error window, like the one above, referring to line 198. Any help would be appreciated.

    Line 80:
    Code:
    var strIDs = '<SELECT SIZE="1" NAME="ACT_droplstbox"
    Line 198:
    Code:
    <form name="Act_SectionDroplist"><script language=Javascript1.1>document.write(ACT_DropListBox(section_tree))</script></form>
    Thanks
    Attached Files

    #2
    You've not posted any URL so it's hard to help.

    Look at the page using Firefox and turn its Tools / JavaScript console on. This will give you a much better idea where the error is.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks, will fire up Firefox ...

      Unfortunately, the site is not uploaded to a remote server yet, and is just being tested locally.

      P.S. I recognise your picture from the site I've just downloaded the drop out menus! Glad to meet you, and I will thank/curse you as I try to figure it all out later

      Comment


        #4
        Firefox Javascript screen shot attached.

        Thanks
        Attached Files

        Comment


          #5
          I think its because when you copied, some code has been split over multiple lines. Copy this instead

          Code:
          function ACT_DropListBox(ar)
          {
          var strIDs = '<SELECT SIZE="1" NAME="ACT_droplstbox" onClick="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">';
          var sel = " SELECTED"
          strIDs += '<OPTION ' + sel + ' VALUE="">Select a Section</OPTION>';
          for (var i=1;i<=ar.length;i++)
          {
          if (ar[i].sURL !=null)
          {
          strIDs += '<OPTION VALUE="' + ar[i].sURL + '">' + ar[i].sName + '</OPTION>';
          {
          if (ar[i].pChild)
          {
          for (var j=1;j<=ar[i].pChild.length;j++)
          {
          strIDs += '<OPTION VALUE="' + ar[i].pChild[j].sURL + '">' + '- ' + ar[i].pChild[j].sName + '</OPTION>';
          {
          if (ar[i].pChild[j].pChild)
          {
          for (var k=1;k<=ar[i].pChild[j].pChild.length;k++)
          {
          strIDs += '<OPTION VALUE="' + ar[i].pChild[j].pChild[k].sURL + '">' + '- - ' + ar[i].pChild[j].pChild[k].sName + '</OPTION>';
          }
          }
          }
          }
          }
          }
          }
          }
          strIDs+='</SELECT>'
          return strIDs
          }
          //-->
          </SCRIPT>
          www.gbradley.co.uk
          Web Development, Actinic Patches, Scripts & more

          Comment


            #6
            That's ue to an error in the Advanced Guide. When the JavaScript got converted to PDF, Acrobat broke some long lines into two separate lines. Fine on a document but fatal on code. Here's the correct version
            Code:
            <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
            <!--
            /***********************************************************************
            *
            * ACT_DropListBox - returns a string containing the HTML for the SELECT listbox
            *
            ************************************************************************/
            function ACT_DropListBox(ar)
            {
            var strIDs = '<SELECT SIZE="1" NAME="ACT_droplstbox" onClick="if(options[selectedIndex].value)window.location.href=(options[selectedIndex].value)">';
            var sel = " SELECTED"
            strIDs += '<OPTION ' + sel + ' VALUE="">Select a Section</OPTION>';
            for (var i=1;i<=ar.length;i++)
              {
              if (ar[i].sURL !=null)
                {
                strIDs += '<OPTION VALUE="' + ar[i].sURL + '">' + ar[i].sName + '</OPTION>';
                if (ar[i].pChild)
                  {
                  for (var j=1;j<=ar[i].pChild.length;j++)
                    {
                    strIDs += '<OPTION VALUE="' + ar[i].pChild[j].sURL + '">' + '- ' + ar[i].pChild[j].sName + '</OPTION>';
                    if (ar[i].pChild[j].pChild)
                      {
                      for (var k=1;k<=ar[i].pChild[j].pChild.length;k++)
                        {
                        strIDs += '<OPTION VALUE="' + ar[i].pChild[j].pChild[k].sURL + ">' + '- - ' + ar[i].pChild[j].pChild[k].sName + '</OPTION>';
                        }
                      }
                    }
                  }
                }
              }
            strIDs+='</SELECT>'
            return strIDs
            }
            //-->
            </SCRIPT>
            I also removed 2 completely redundant sets of { .. }.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              Many thanks, that did the trick!

              Is there any where online I can cut n paste the code from? As opposed to just from the PDF.

              Thanks.

              Comment

              Working...
              X