Greg Morphis wrote:
> Say I have a query that returns some values
> rownum, id, and desc
>
> 1 1001 ProductA
> 2 1002 ProductB
> 3 1003 ProductC
> 4 1004 ProductD
> 5 1005 ProductE
>
> Is it not possible (without opening a new frame) to use Javascript to
> get a certain row?
> I was thinking something on the lines of
> <a href="Javascript:getDesc(#qry.rownum#)">#qry.id#</a>
>
> <div id="sDiv">
> Description
> </div>
>
> How would I access the value?
> I've tried
>
> <script language="Javascript">
> <!--
> function getDesc(num)
> {
> var rn = num;
> val = "evaluate(test.agentpw["+ rn +"])";
> alert(<cfoutput>#val#</cfoutput>);
>
> }
> //-->
> </script>
>
> But I keep getting val is undefined.
> The structure exists, I can get any value manually by #qry.desc[1]#.
> It sounds fairly simple what am I doing wrong?
What I think you need to do is something like this:
<!--- BEGIN --->
<cfquery name="foo">
SELECT id, desc
FROM products
</cfquery>
<!---
Output a JavaScript dictionary mapping product ids onto their
descriptions.
--->
<script type="text/javascript">
var products =
{
<cfoutput query="foo">
#id#: "#JSStringFormat(desc)#"
<cfif CurrentRow NEQ RecordCount>,</cfif>
</cfoutput>
};
function getDesc(id)
{
alert(products[id]);
}
</script>
<table>
<cfoutput query="foo">
<tr>
<td><a href="javascript:getDesc(#id#)">#id#</td>
</tr>
</cfoutput>
</table>
<!--- END --->
The mistake I think you're making is confusing ColdFusion and
JavaScript. JavaScript can't see any of CFs queries. Instead, you
need to generate a JS datastructure to hold the results yourself
and then use JS to query this.
K.
--
Keith Gaughan, Developer
Digital Crew Ltd., Pembroke House, Pembroke Street, Cork, Ireland
http://digital-crew.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - RUWebby
http://www.ruwebby.com
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186804
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54