• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Drop Down Navigation

Explorer ,
Jun 27, 2006 Jun 27, 2006

Copy link to clipboard

Copied

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

Jim
TOPICS
Advanced techniques

Views

444

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 27, 2006 Jun 27, 2006
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.

Votes

Translate

Translate
LEGEND ,
Jun 27, 2006 Jun 27, 2006

Copy link to clipboard

Copied

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.
</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 27, 2006 Jun 27, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2006 Jun 27, 2006

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation