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

发布于 2018-04-13 21:13:54
如果没有数据转储,就很难知道数据是如何实际存储的,这使得这个问题有点混乱。
"depthinput1“、"depthinput2”是查询中列的名称吗?
RecordID | DepthInput1 | DepthInput2 | ... | DepthInputN
1 | 35.5 | 86.2 | ... | 14.6 ..。还是"depthInput“值实际上存储在单独的行中?
RecordID | DepthInput
1 | 35.5
2 | 86.2
....
86 | 14.6 如果它们是查询列,请考虑重新构造数据库表。类似的列名如"thing1","thing2",.通常是一个指示符,数据应该存储在单独的行中(如上面所示)。如果确实无法更改结构,请使用关联数组符号动态访问查询列,queryName["columnName"][rowNumber]#
<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作为索引。
<cfoutput query="flowQy">
<input name="depthInput#flowQy.currentRow-1#"
value="#flowQy.depthInput#"><br>
</cfoutput>发布于 2018-04-13 19:39:42
我想你想要的更像是:
<cfoutput query="flowQy">
<input name="depthinput#currentRow#" type="text" ... value="#somecolumninQuery#" id="depthinput#currentRow#" />
</cfoutput>很难知道您的代码正在尝试做什么,或者您试图引用的数据到底在哪里。
https://stackoverflow.com/questions/49820650
复制相似问题