3 Replies Latest reply on Jun 27, 2006 12:11 PM by Dan Bracuk

    Drop Down Navigation

      Hi, I have a query that pulls product categories from the DB, I am using a drop down type navigation. I want to dynamically fill the drop down array with the values from the query. I am not sure how to increase the line number for each value.

      Here is the menu script

      var menu2=new Array()
      menu2[0]='<a href="projectresultsnew.cfm?cid=#category.categoryid #">#category.category#</a>'
      menu2[1]='<a href="projectresultsnew.cfm?cid=#category.categoryid #">#category.category#</a>'
      menu2[2]='<a href="projectresultsnew.cfm?cid=#category.categoryid #">#category.category#</a>'

      So essentially I need to repeat line 2 over and over and increase the menu line number each time. Any ideas. Arrays are just not my strong suit. Thanks

        • 1. Re: Drop Down Navigation
          Dan Bracuk Level 5
          Idea number 1 - don't use an array.

          If the intent is to display a bunch of links, why not do something like:
          <cfoutput query="something">
          <a href="projectresultsnew.cfm?cid=#category.categoryid#">#category.category#</a>
          Something to separate links.
          • 2. Re: Drop Down Navigation
            jazz823 Level 1
            Thanks, however it is a drop down navigation with the mouse overs and what not, so when you mouse over the heading it displays all the links under it. It is a dhtml menu.

            That was the reason for the array, because each menu line had to be unique.
            • 3. Re: Drop Down Navigation
              Dan Bracuk Level 5
              If you are running version 7, you can use the toScript function to pass cf variables to js. Also, each query column can be treated as an array, but the syntax is tricky.

              Those two bits of info will allow you to send the categoryid and category fields to js as arrays. Then you just loop through one of them to build your menu.