gpt4 book ai didi

javascript - 在 javascript 中调用 cfquery 但它没有执行任何操作

转载 作者:行者123 更新时间:2023-11-28 09:18:00 25 4
gpt4 key购买 nike

我正在尝试使用 Coldfusion (cfquery) 创建一个查询来检索几个美元金额,将它们相加,然后查看它是否与应用程序中计算的美元金额匹配。但是,它没有做任何事情。

我正在尝试在 JavaScript 中完成所有这些操作。

这是代码。

function ValidateFunding(){
var casenum = document.getElementById('CaseNum').value;
var cycle = document.getElementById('Cycle').value;
var year = document.getElementById('FSYear').value;
var cnty = document.getElementById('selCounty');
var cntyID = cnty.options[cnty.selectedIndex].value;

<cfquery name="PSP" datasource="QueryTest">
SELECT g.Fee220 + g.Fee330 + g.Fee456 + g.Fee225 AS GrandTotal
FROM ProgFees g INNER JOIN County ON g.CountyID = cntyID
WHERE g.Year = year
AND g.Cycle = cycle
AND g.CaseNum = casenum
</cfquery>
if (document.getElementById('totbud').value = PSP.GrandTotal){
alert('The fee matches.');
return false;
}
else
{
alert('Fees do not match.');
}
return true;
}

最佳答案

这是我为测试而制作的页面。代码中有注释可以帮助解释发生了什么。两个关键行是 <cfajaxproxy>标签和jd.getData();是我对 CF 的 AJAX 调用。

<cfscript>
variables.folders = {"client":["Favorites","Not Used"],"org":["2012","2011"],"public":["New","Old"]};
</cfscript>
<cfajaxproxy cfc="cfc.jsondata" jsclassname="emaildata" />
<!DOCTYPE html>
<html>
<head>
<title>DevJSON</title>
<script src="js/jquery.1.7.2.js" type="text/javascript" language="JavaScript"></script>
<script src="js/handlebars.js" type="text/javascript" language="JavaScript"></script>
<link rel="stylesheet" href="css/json.css" type="text/css"/>
<script type="text/javascript">
<!--- toScript will output CF vars as js vars --->
<cfoutput>
var #toScript(variables.folders, 'folders')#;
var #toScript(cgi.http_host & '/data/emaildata.json','jsonPath')#;
</cfoutput>
var jd = new emaildata();
// setup my js object from cfajaxproxy above

var buildGrid = function(dataObj){
var menus;
var source = $('#grid').html();
var template = Handlebars.compile(source);
$("#mainContent").hide();
$("#mainContent").children().remove();
$("#mainContent").append(template(dataObj));
$("#mainContent").fadeIn('slow');
}

// Error handler for the asynchronous functions.
var badJson = function(statusCode, statusMsg){
alert('Status: ' + statusCode + '<br /><br /> ' + statusMsg);
}

// output data
var buildmenu = function(){
$.each(folders, function(fkey,fval) {
if(this.indexOf() < 1){
$('li[data-type="' + fkey + '"] > div').append('<ul class="' + fkey + '"></ul>');
}
$.each(fval, function(dkey, dval){
$('[class="' + fkey + '"]').append('<li id="' + fkey + '">' + dval + '</li>');
});
});
}

$(document).ready(function(){
buildmenu();
$('.directory > ul > li').click( function() {
//set callback, errorhandler and then call the getData function in my CFC
jd.setCallbackHandler(buildGrid);
jd.setErrorHandler(badJson);
jd.getData(this.id);
$(".directory > ul > li").removeClass("highlight");
$(this).addClass('highlight');
});
$("#mainContent").css('display','none');
$('li[data-type]').css('cursor','pointer');

});

</script>
<!--- Setup handlebars template --->
<script id="grid" type="text/x-handlebars-template">
<div class="gridDetail">
{{#each DATA}}
<div class="row">
{{#each this}}
<span class="cell">
{{.}}&nbsp;
</span>
{{/each}}
</div>
{{/each}}
</div>
</script>
</head>

关于javascript - 在 javascript 中调用 cfquery 但它没有执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15394049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com