0

我正在尝试显示数据库中的数据并在每行的末尾添加一个复选框。我已经尝试过 html 标签和 CF 标签,但在过去的几个小时里我遇到了错误。任何帮助都会很棒,因为我对 ColdFusion 完全陌生。继承人的代码:

<cfset a = "BGCOLOR =###IIF(myQuery.currentrow MOD 2, DE('E6E6E6'),DE('C0C0C0'))#" />

<cfscript>
    For (i=1;i LTE myQuery.recordCount; i=i+1)


     writeoutput ("<TR " & a & "><TD>" & i & "</TD>" &
      "<TD>" & myQuery.UserID[i] & "</TD>" &
      "<TD>" & myQuery.FName[i] & "</TD>" &
      "<TD>" & myQuery.SName[i] & "</TD>"&
      "<TD>" & myQuery.Phone[i] & "</TD>"&
      "<TD>" & myQuery.DateJoined[i] & " </TD>"&
      "<TD>" & myQuery.Address[i] & "</TD>"&
      "<TD>" & <cfinput type="Checkbox" name="post_home">  & " </TD></TR>");


    </cfscript>

最后一行(第 55 行)导致错误.. 提前致谢

在第 55 行第 37 列发现无效的 CFML 构造。

ColdFusion 正在查看以下文本:复选框

  The CFML compiler was processing:

  An expression beginning with writeoutput, on line 48, column 1.This message is usually   caused by a problem in the expressions structure.
  A script statement beginning with writeoutput on line 48, column 1.
  A script statement beginning with For on line 45, column 9.
  A cfscript tag beginning on line 44, column 2.
  A cfscript tag beginning on line 44, column 2.
  A cfscript tag beginning on line 44, column 2.

  The error occurred in C:/inetpub/wwwroot/sem2/aShowUsers.cfm: line 55
  53 :           "<TD>" & myQuery.DateJoined[i] & " </TD>"&
  54 :           "<TD>" & myQuery.Address[i] & "</TD>"&
  55 :        "<TD><input type="checkbox" name="post_home"></TD></TR>");
  56 : 
  57 : 
  Resources:
  Check the ColdFusion documentation to verify that you are using the correct syntax.
  Search the Knowledge Base to find a solution to your problem.
  Browser   Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko)      Chrome/26.0.1410.64 Safari/537.31
  Remote Address    ::1
  Referrer      http://localhost/Sem2/adminmainpage.cfm
  Date/Time     13-May-13 10:08 PM
  Stack Trace


 coldfusion.compiler.ParseException: Invalid CFML construct found on line 55 at column 37.
at coldfusion.compiler.cfml40.generateParseException(cfml40.java:13130)
at coldfusion.compiler.cfml40.jj_consume_token(cfml40.java:13001)
at coldfusion.compiler.cfml40.FunctionParameters(cfml40.java:6523)
at coldfusion.compiler.cfml40.ComplexReference(cfml40.java:6381)
at coldfusion.compiler.cfml40.VariableReference(cfml40.java:6300)
at coldfusion.compiler.cfml40.PrimaryExpression(cfml40.java:6105)
at coldfusion.compiler.cfml40.UnaryExpression(cfml40.java:5955)
at coldfusion.compiler.cfml40.ExponentialExpression(cfml40.java:5912)
at coldfusion.compiler.cfml40.MultiplyDivisionExpression(cfml40.java:5865)
at coldfusion.compiler.cfml40.IntegerDivisionExpression(cfml40.java:5846)
at coldfusion.compiler.cfml40.ModExpression(cfml40.java:5827)
at coldfusion.compiler.cfml40.AdditionExpression(cfml40.java:5780)
at coldfusion.compiler.cfml40.ConcatExpression(cfml40.java:5761)
at coldfusion.compiler.cfml40.ComparisonExpression(cfml40.java:5614)
at coldfusion.compiler.cfml40.NotExpression(cfml40.java:5564)
at coldfusion.compiler.cfml40.AndExpression(cfml40.java:5536)
at coldfusion.compiler.cfml40.OrExpression(cfml40.java:5517)
at coldfusion.compiler.cfml40.XorExpression(cfml40.java:5498)
at coldfusion.compiler.cfml40.EqvExpression(cfml40.java:5479)
at coldfusion.compiler.cfml40.ImpExpression(cfml40.java:5460)
at coldfusion.compiler.cfml40.HookExpression(cfml40.java:5415)
at coldfusion.compiler.cfml40.expr(cfml40.java:5399)
at coldfusion.compiler.cfml40.cfScriptExpression(cfml40.java:2576)
at coldfusion.compiler.cfml40.SimpleStatement(cfml40.java:643)
at coldfusion.compiler.cfml40.cfscriptStatement(cfml40.java:1595)
at coldfusion.compiler.cfml40.ComplexStatement(cfml40.java:1710)
at coldfusion.compiler.cfml40.cfscriptStatement(cfml40.java:1530)
at coldfusion.compiler.cfml40.cfscript(cfml40.java:1455)
at coldfusion.compiler.cfml40.cfml(cfml40.java:4568)
at coldfusion.compiler.cfml40.cfelse(cfml40.java:442)
at coldfusion.compiler.cfml40.cfif(cfml40.java:316)
at coldfusion.compiler.cfml40.cfml(cfml40.java:4554)
at coldfusion.compiler.cfml40.cfelse(cfml40.java:442)
at coldfusion.compiler.cfml40.cfif(cfml40.java:316)
at coldfusion.compiler.cfml40.cfml(cfml40.java:4554)
at coldfusion.compiler.cfml40.start(cfml40.java:4994)
at coldfusion.compiler.NeoTranslator.parsePage(NeoTranslator.java:694)
at coldfusion.compiler.NeoTranslator.parsePage(NeoTranslator.java:675)
at coldfusion.compiler.NeoTranslator.parseAndTransform(NeoTranslator.java:428)
at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:370)
at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:147)
at coldfusion.runtime.TemplateClassLoader$TemplateCache$1.fetch(TemplateClassLoader.java:436)
at coldfusion.util.LruCache.get(LruCache.java:180)
at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial(TemplateClassLoader.java:362)
at coldfusion.util.AbstractCache.fetch(AbstractCache.java:58)
at coldfusion.util.SoftCache.get_statsOff(SoftCache.java:133)
at coldfusion.util.SoftCache.get(SoftCache.java:81)
at coldfusion.runtime.TemplateClassLoader.findClass(TemplateClassLoader.java:609)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:101)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:30)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
at coldfusion.CfmServlet.service(CfmServlet.java:204)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:203)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
4

3 回答 3

4

您的<cfinput>标签周围缺少引号。您需要在此处使用单引号来正确连接。

<cfscript>
for ( i=1; i <= myQuery.recordCount; i++ ) {

  writeoutput ("<tr " & a & "><td>" & i & "</td>" &
  "<td>" & myQuery.UserID[i] & "</td>" &
  "<td>" & myQuery.FName[i] & "</td>" &
  "<td>" & myQuery.SName[i] & "</td>" &
  "<td>" & myQuery.Phone[i] & "</td>" &
  "<td>" & myQuery.DateJoined[i] & "</td>" &
  "<td>" & myQuery.Address[i] & "</td>" &
  "<td>" & '<input type="checkbox" name="post_home">' & "</td></tr>");

}
</cfscript>

或者,您可以将最后一行全部放在单引号中。

'<td><input type="checkbox" name="post_home"></td></tr>');
于 2013-05-13T21:32:45.267 回答
1

你可以用简单的方法做到这一点,而无需使用 cfscript。

<cfoutput query = "myQuery">
<tr>
    <td>#myQuery.userid#</td>
    ... other display fields
    <td><input type="checkbox" name="post_home" value="#something#"></td>
</tr>
</cfoutput>
于 2013-05-13T21:42:20.203 回答
0

请记住,您没有a在示例中定义,并且复选框将没有要传递的值,因为它没有定义。另外,不要在ivar 周围放置散列。

<cfscript>
        for ( i=1; i <= myQuery.recordCount; i++ ) {

             writeoutput ("<tr " & myQuery.currentRow MOD 2 ? '##E6E6E6' : '##C0C0C0' & "><td>" & i & "</td>" &
                "<td>" & myQuery.UserID[i] & "</td>" &
                "<td>" & myQuery.FName[i] & "</td>" &
                "<td>" & myQuery.SName[i] & "</td>" &
                "<td>" & myQuery.Phone[i] & "</td>" &
                "<td>" & myQuery.DateJoined[i] & "</td>" &
                "<td>" & myQuery.Address[i] & "</td>" &
                "<td><input type='checkbox' name='post_home'></td></tr>");

            }
</cfscript>
于 2013-05-13T21:03:33.063 回答