Skip to main content
June 4, 2008
Question

Dynamically show 1 row of a cold fusion query

  • June 4, 2008
  • 2 replies
  • 955 views
Hey everyone,
A simple question, I am just have a hard time figuring out the most effecient and easy way to do this. Say I have a query like

<cfquery name="getcrap" datasource="users">
SELECT NAME, ID, JOBROLE
FROM PEOPLE
</cfquery>

<select name="listpeople" OnChange="SOME_MAGIC_JS_FUNCTION(this.value)">
<cfloop query="getcrap">
<option value="#getcrap.id#">#getcrap.name#</option>
</cfloop>
</select>
<div id="showdetails">I WANT THE JOB ROLE THE PERSON TO DISPLAY HERE</div>

How can I make that work. Basically a query pulls some values, I loop through the values creating a dropdown list item for each person, and want to show more in depth info on that person when they are selected from the dropdown list. I think I would have to load the data from the cold fusion query into a javscript array or something then display the element of the array signified by the ID passed to the function, but I'm not real sure how to do that. Anybody have any sample code for how to do this?

This topic has been closed for replies.

2 replies

Inspiring
June 4, 2008
quote:

Originally posted by: kenji776
I think I would have to load the data from the cold fusion query into a javscript array or something then display the element of the array signified by the ID passed to the function, but I'm not real sure how to do that. Anybody have any sample code for how to do this?


That's pretty close. To the best of my knowlege, js only supports 1D arrays, so you would need an array for every query field.

You are attempting something similar to Related Selects. Here is some sample code for that, http://www.pathcom.com/~bracuk/code/RelatedSelects.htm . You'll just have to adapt it to your own requirements.
June 4, 2008
Dan, thanks for the info. That link you posed is dead however. I went and checked quick, and it does seem as though Javascript supports multidimensional arrays.
http://www.devx.com/tips/Tip/12455
Unless I'm reading that wrong (I'm sorta a novice programmer, so very likely I misinterpreted that). Can you repost link? Thanks.
June 4, 2008
I figured it out.
Inspiring
June 4, 2008
Javascript.

Adobe has a free library called Spry.

http://labs.adobe.com/technologies/spry/samples/
June 4, 2008
Thanks for the reply, I might look at that. I think I am real close using the toscript function. I get a result that looks like
WDDXQuery = new WddxRecordset(); col0 = new Array(); col0[0] = "Bob Jones" .....; Using toscript I can turn the query results into a javascript array, but I can't seem to really do anything with it. Attached is the code I have so far.