coldfusion输入类型=“隐藏”不隐藏

Bet*_*ock 2 coldfusion hidden input cfml

我有一个传递变量的表格,里面有很多隐藏的输入,然后是一个提交。这是一些代码:

<input type = "hidden" name =  "templname" value =  '#templname#'>
<input type = "hidden" name =  "attloc"    value = '#extattloc#'>      
 <input type = "hidden" name =  "cctype"    value = 'f'>
 <input type = "hidden" name =  "merls"     value = '#merls#'>
  <input type = "hidden" name =  "invnum"    value = '#invnum#'>

  <cfif ArrayIsDefined(selvalarr,1)>
        <cfloop array = "#selvalarr#" index = "att"> 
           <input type = "hidden" name = "att" value ="#att#">
        </cfloop>
   </cfif>

   <cfloop array = "#letarr#" index = "let">
    <input type = "hidden" name =  "let" value = '#let#'>
   </cfloop>

     <input type   = "submit" 
           class   = 'repbutton onoffbut'  
           style   = 'height:75px;'             
           id      = "runemail"                             
           value   = "run email"  >
  </form>
  </td>  
Run Code Online (Sandbox Code Playgroud)

一切都是您所期望的-除了letarr上的循环。尽管输入明显被隐藏,但变量#let#正在转储到页面上。这是变量“ let”的样子(2个值)。此输出来自以下代码:

<cfloop array = "#letarr#" index = "let">
<br>#let#     
</cfloop>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

这是隐藏的输入给我的:

在此处输入图片说明

除了“运行电子邮件”按钮外,什么都没有。

我已经完成了数组“ letarr”的直接输出,并且它是正确的(请参见上文)。我检查过,将其包含在<td标签中不是问题。我认为这与变量有关,也许是多行。

有没有人知道是什么原因造成的?或如何解决?

Jam*_*ler 5

做几个步骤。

  1. 进行操作<cfdump var="#letarr#">以确保没有意外值。

  2. 确保保护变量免受注入

    <cfloop array = "#letarr#" index = "let">
      <input type = "hidden" name =  "let" value = '#EncodeForHTMLAttribute(let)#'>
    </cfloop>
    
    Run Code Online (Sandbox Code Playgroud)
  3. 我真的很想知道是否有缺失的引号或奇怪的东西看起来像字符串中的引号。我会找一个回勾,一个聪明的(又名哑巴)报价和重音符号之类的东西。您的结果看起来像是放弃了HTML