首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用cfloop索引的表单值

使用cfloop索引的表单值
EN

Stack Overflow用户
提问于 2018-04-13 15:38:15
回答 2查看 416关注 0票数 0

我使用cfloop创建表单,并使用数据库查询中的值填充文本字段。我还创建了一个数组。它在输入框中返回"depthinput1“、"deptinput2”等,而不是数据库字段中的值。任何帮助都将不胜感激。

代码语言:javascript
复制
<cfloop index="i" from="0" to="#totalsegment-1#">
    <cfloop query="flowQy" startrow="1" endrow="#totalsegment-1#">

    <cfset newarray =ArrayNew(1)>
    <cfset depthinput=structNew()>
    <cfset depthinput[i] = "depthinput" & i>
    <cfset arrayAppend(newarray, depthinput)>
    <cfinput name="depthinput#i#"  tabindex="#((i+1)*2)-1#" type="text"  onfocus="this.value='';findTotal();" size="10" onblur="findTotal();" value='#depthinput[i]#'  id="depthinput#i#"></cfinput></br>

    </cfloop>
</cfloop>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-04-13 21:13:54

如果没有数据转储,就很难知道数据是如何实际存储的,这使得这个问题有点混乱。

"depthinput1“、"depthinput2”是查询中列的名称吗?

代码语言:javascript
复制
RecordID | DepthInput1 | DepthInput2 | ... | DepthInputN
1        |     35.5    | 86.2        | ... |    14.6   

..。还是"depthInput“值实际上存储在单独的行中?

代码语言:javascript
复制
RecordID | DepthInput 
1        |    35.5    
2        |    86.2 
....
86       |    14.6  

如果它们是查询列,请考虑重新构造数据库表。类似的列名如"thing1","thing2",.通常是一个指示符,数据应该存储在单独的行中(如上面所示)。如果确实无法更改结构,请使用关联数组符号动态访问查询列,queryName["columnName"][rowNumber]#

代码语言:javascript
复制
<cfoutput query="flowQy">
   <!--- determines which columns to display:  -->
   <cfloop from="0" to="#totalSegment#" index="i">
    <input name="depthInput#i#" value="#flowQy['depthInput'& i+1][flowQy.currentRow]#"><br>
   </cfloop>
</cfoutput>

如果值实际上存储在单独的行中,只需循环查询并使用queryName.currentRow作为索引。

代码语言:javascript
复制
<cfoutput query="flowQy">
    <input name="depthInput#flowQy.currentRow-1#" 
        value="#flowQy.depthInput#"><br>
</cfoutput>
票数 2
EN

Stack Overflow用户

发布于 2018-04-13 19:39:42

我想你想要的更像是:

代码语言:javascript
复制
<cfoutput query="flowQy">
 <input name="depthinput#currentRow#" type="text" ... value="#somecolumninQuery#" id="depthinput#currentRow#" />
</cfoutput>

很难知道您的代码正在尝试做什么,或者您试图引用的数据到底在哪里。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49820650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档