小编dra*_*354的帖子

ColdFusion CFIF

我是ColdFusion的新手.我正在尝试进行一些表单字段验证.但是,如果form.nameform.address字段为空,我的CFIF似乎不起作用.

这是我的代码:

         <cfif IsDefined("form.name")>
           <cfif IsDefined("form.address")>
              Your shipping address is:<br>
              <cfoutput>
                 #form.name#<br>
                 #form.address#<br>
                 #form.state#<br>
                 #form.shipping#<br>
                 #form.brochure#<br>
              </cfoutput>

           <cfelse>
              You did not enter an address.
           </cfif>   
         <cfelse>
              You did not enter a name.
         </cfif>  
Run Code Online (Sandbox Code Playgroud)

validation coldfusion

2
推荐指数
1
解决办法
359
查看次数

Coldfusion Application.cfc

这可能是一个愚蠢的问题,但是当我的数据源位于cfm页面时,它可以正常工作,但是当我将数据源放在我的application.cfc中时,它会出错.

来自CFM文件的代码

<cfquery name = "getlist" datasource="jeb48_shoppingcart">
 SELECT ProductID, ProductName, ProductQty, ProductPrice, ProductDescription
 FROM Products;
</cfquery>
Run Code Online (Sandbox Code Playgroud)

来自CFC的代码

<cfcomponent> 
   <cfset This.name = "TestApplication"> 
   <cfset This.clientStorage = "jeb48_northwind"> 
   <cfset This.clientmanagement="True"> 
   <cfset This.loginstorage="Session"> 
   <cfset This.sessionmanagement="True"> 
   <cfset This.sessiontimeout="#createtimespan(0,0,10,0)#"> 
   <cfset This.applicationtimeout="#createtimespan(5,0,0,0)#"> 
</cfcomponent>
Run Code Online (Sandbox Code Playgroud)

coldfusion application.cfc

0
推荐指数
1
解决办法
385
查看次数

标签 统计

coldfusion ×2

application.cfc ×1

validation ×1