在javascript中调用cfquery,但它没有做任何事情



我尝试使用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>

相关内容

  • 没有找到相关文章

最新更新