有没有更简单的方法来操作 Coldfusion 中的复选框?
基本上,我已将信息存储在数据库字段中,我想通过表单再次显示它。
原始表单具有相同的复选框,但它们始终为空。用户可以勾选复选框并将值放入数据库中。
研究生课程:秋季?春天?夏天?以列表形式存储在名为 grad 的列中。 (F、M、S)
他们可以选择将这个可爱的表格保存为草稿。当他们回到草稿时,我需要展示他们可能已经检查过的内容。
<cfif listContains(#grad#, "F") is not 0>
<input type="checkbox" name="grad" id="grad" value = "F" checked />
<cfelse>
<input type="checkbox" name="grad" id="grad" value = "F" />
</cfif>
<cfif listContains(#grad#, "S") is not 0>
<input name="grad" type="checkbox" id="grad" value = "S" checked />
<cfelse>
<input name="grad" type="checkbox" id="grad" value = "S" />
</cfif>
<cfif listContains(#grad#, "M") is not 0>
<input name="grad" type="checkbox" id="grad" value = "M" checked />
<cfelse>
<input name="grad" type="checkbox" id="grad" value = "M" />
</cfif>
有没有更简单的方法可以使用 cfform 代码执行此操作?
只是好奇。 :)
Basically, I have stored information in a database field and I want to display it again through a form.
The original form has the same checkboxes but they are always empty. The user can check the boxes off and the values are put into the database.
Graduate Courses: Fall? Spring? Summer? Stored as a list in a column named grad. (F, M, S)
They have the option to save this lovely form as a draft. When they come back to the draft I need to display what they might have already checked.
<cfif listContains(#grad#, "F") is not 0>
<input type="checkbox" name="grad" id="grad" value = "F" checked />
<cfelse>
<input type="checkbox" name="grad" id="grad" value = "F" />
</cfif>
<cfif listContains(#grad#, "S") is not 0>
<input name="grad" type="checkbox" id="grad" value = "S" checked />
<cfelse>
<input name="grad" type="checkbox" id="grad" value = "S" />
</cfif>
<cfif listContains(#grad#, "M") is not 0>
<input name="grad" type="checkbox" id="grad" value = "M" checked />
<cfelse>
<input name="grad" type="checkbox" id="grad" value = "M" />
</cfif>
Is there an easier method to doing this with cfform code?
Just curious. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我这样做是因为我并没有真正使用
:但是 ColdFusion 文档指出:
所以,是的,
可以帮助您解决此问题。使用
模拟正常请求的“发布值”。I do it like this, as I don't really use
<cfform>
:But the ColdFusion docs state:
So yes,
<cfform>
can help you with this. Use<cfparam name="FORM.xyz" default="foobar">
to emulate the "posted value" for normal requests.