且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从解析的字符串创建两个变量

更新时间:2023-11-15 11:39:16

<cfset recIds = []>
<cfset distListNames = []>
<cfloop list="#form.Listname#" index="checkboxValue">
  <cfset arrayAppend(recIds, listFirst(checkboxValue, ':'))>
  <cfset arrayAppend(distListNames, ListRest(checkboxValue, ':'))>
</cfloop>

我应该研究一种不同的方式来传递RecID和名称吗?

should I look into a different way of passing the RecID and name?

将复选框的值仅设置为RecID是合乎逻辑的,因为名称仅显示在确认页面上".然后,您可以从form范围中免费获取一个RecIDs列表,以备使用.确认页面是CFM页面吗?如果是这样,您是否无法显示通过ID从数据库再次获取的名称?

It'd be logical to only set the value of checkbox to RecID, since "the name is just displayed on the confirmation page". Then you get a list of RecIDs from the form scope, ready to be used, for free. Is the confirmation page a CFM page? If so, couldn't you display the name(s) that by fetching from DB again by ID(s)?