Hi Patric,

I'll try to consolidate information I've provided so far. I'm not at work today so I can't generate the exact code, but I'll do my best to simulate it.

Here goes:

Purpose of the code:
When a user clicks on a menu link (generated by the CF code prior to the user interaction), an associated DIV with an ID equal to the stylename displays its content. This is because the onClick event tells the matching style in the stylesheet to change "display=none" to "display=block".

These are a sample of the values in the stylesheet:
#FellSvc{display:none;}
#MinorRts{display:none;}
#AmnInf{display:none;}
#AnteSter{display:none;}

The names of these styles are included as a column (menu_bmarkLink) in the db table.
Other relevant columns in the db table are: menu_Text and menu_nonBmarkLink. For the issue at hand, the column menu_Text and
menu_bmarkLink.

(menu_nonBmarkLink is included in the query for a condition where a link doesn't have a bookmark, but has an external link instead. I don't think that matters for this post.)

The query is something like this:
<cfquery name="q_menu" dbname="faqmch">
Select * from faq_menulinks
</cfquery>

The output would be something like this:
menu_Text  menu_bmarkLink   menu_nonBmarkLink
link1      MinorRts
link2      FellSvc
link3      AmnInf
link4      AnteSter
link5                       http://gosomewhereelse.com

My output would be inserted into HTML list items something like this:
<cfoutput query="q_menu">
<li><A HREF="" q_menu.menu_nonBmarkLink neq
"">"#q_menu.menu_nonBmarkLink#"><cfelse>"##Ans"
</a> </li>
</cfoutput>

which could produce output like:
<li><A HREF=""
<li><A HREF=""
<li><A HREF=""
<li><A HREF=""
<li><A HREF="" </a> </li>

For links 1-4, the "#Ans" is the position in the screen where the content is displayed now that the onClick target style is set to display=block. (As mentioned previously, there is a div with the same name as the style that contains the content.

Something like this:

<div id="MinorRts">A minor has a lot of rights but they never think they have enough. They think they're old enough to make
decisions for themselves, but some of those decisions could be deadly. <a href="" content</a></div>

If the solution to my problem is including another set of <cfoutput> tags somewhere in this code so that the value for:#menu_bmarkLink# displays properly (a different value for it in each list item instance), then great.

<cfoutput query="q_menu">
<li><A HREF="" q_menu.menu_nonBmarkLink neq "">"#q_menu.menu_nonBmarkLink#"><cfelse>"##Ans"
</a> </li>
</cfoutput>

I got on this not-so-wild ride, when I got an error on the output code  above saying something like, "onClick didn'tunderstand the variable". I took the tact of trying to make the #menu_bmarkLink# a js variable - which worked, but only to the extent that it returned only one value for the variable and repeated that value in each instance of a generated list item.

Can you help?
Appreciatively,
Joy

> The concept that took me awhile to get my head around.  You don't
> usually pass variables to _javascript_ in examples like this.  If you
> need to truly pass variables to _javascript_ from CFML you need to use
> some kind of intermediary technology such as WDDX.  But for what you
> seem to be trying to do, you just need to create some dynamically
> written _javascript_.  This works just like dynamically written HTML
> that we all do on a daily basis.  All the CFML mixed with _javascript_
> code is rendered in the server and the completed _javascript_ is sent to
> the client where it is ran.  Some basic examples:


>
> To create a list of links with a dynamic _javascript_ phrase:


>
> <cfoutput query="aQuery">
   
> <a href="" > > aColumn#')">#aQuery.anotherColumn#</a>
> </cfoutput>


>
> A gotcha in this syntax is the mixing of quotes on the onClick
> property.  If you want the parameter of the JS function to be a string
> literal wrapped in quotes and the onClick property to be correctly
> wrapped in quotes you must properly nest double (") and single (')
> quotes.  Also, if the JS complains about the string #aQuery.aColumn#,
> then the CFML variable was not rendered, which means that is was not
> inside <cfoutput> tags for some reason.


>


>


>


>
> To create a dynamically generated JS function:


>
> <script>


>
> function aJSfunction ( foo, bar )
> {
   
> var sampleArray = new Array(1);


>
   
> <cfoutput query="aQuery">
        
> sampleArray[currentRow] = "#aQuery.aColumn#";
   
> </cfoutput>
> }
> </script>


>
> This would create a simple JS array out of the values in a column from
> a CFML query.  This could also be done with WDDX if one so desired.  
> If you are using a Macromedia IDE such as Studio, Homesite or
> Dreamweaver, the color coding feature gets confused with this kind of
> mixing of JS and CFML code, but that has no bearing on the correctness
> of the code so just ignore the strange coloring of the code.


>
> HTH


>
> If you are still unsure of how to accomplish your requirements and if
> you can provide a couple of snippets of your actual code we can
> probably help you more specifically with your syntax.


>
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> www.BloodSource.org
> Sacramento, CA
>
> "C code. C code run. Run code run. Please!"
     
> - Cynthia Dunning
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to