无法访问脚本中ColdFusion标记中的JavaScript变量 [英] Unable to access JavaScript variables in ColdFusion tags in script

查看:100
本文介绍了无法访问脚本中ColdFusion标记中的JavaScript变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试从select标签中获取选定的值,并将其传递给jquery中的冷融合标签,如下所示.

I was trying to take the selected value from the select tag and pass it to cold fusion tags in jquery as follows.

选择标记代码:

<select id="selectco">
<cfoutput query="colist">
<option value="#cid#">#coname#</option>
</cfoutput>
</select>

jQuery代码:

$(document).ready(function() 
{
    $("#selectco").change(function() 
    {
        var e=document.getElementById("selectco");
        var opt=e.options[e.selectedIndex].value;
         $("#selectst").html("<cfquery name='stlist' datasource='tasks'>
select * from state where cid='"+opt+"'
</cfquery><select id='selectct'><cfoutput query='stlist'><option>#stname#</option></cfoutput>");
    });
});

我能够将值用作opt变量.但是无法将值传递给cfquery标记.请帮助我.

I was able to take the value to opt variable.But am unable to pass the value to the cfquery tag. Please help me.

推荐答案

CFML在ColdFusion服务器上解析; Javascript在客户端浏览器上运行.两者从未在同一空间存在".

CFML is parsed on the ColdFusion server; Javascript runs on the client browser. The two never "exist" in the same space.

我建议您阅读我的博客文章,其中介绍了CF如何参与一个请求.

您需要做的是阅读数据绑定(或一般而言)在ColdFusion (或一般情况下)中进行了记录,因此在此处复制它毫无意义.

What you need to do is to read up on data binding in ColdFusion (or in general), which is fairly well documented, so there's little point in replicating it here.

这篇关于无法访问脚本中ColdFusion标记中的JavaScript变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆