从解析的字符串创建两个变量
我正在尝试将字符串解析为两个变量.源是一个SQL查询,该查询填充多个复选框的值.复选框的数量根据查询结果而有所不同.复选框编码为:
I'm trying to parse a string into two variables. The source is a SQL query that populates values for multiple checkboxes. The number of checkboxes varies base on the query results. The checkboxes are coded:
<input type="checkbox" name="Listname" value="#RecID#:#DistListName#" ID="ListName#ListID#">
使用在这里找到的代码,我将:
移除,将RecID和DistListName分隔为:
Using code I found here, I remove the :
separating RecID and DistListName with:
<cfset PreParseList = #form.Listname#>
<cfset ParseList = ListToArray(PreParseList, ":", false, true)>
ParseList的输出如下所示:
The output of ParseList looks like this:
627 Corporate IT Desktop Team DL,629 Corporate IT Helpdesk Team DL,607 HMC Behavioral Health DL,257 Kauai Region HR
我需要创建两个变量,一个用于RECID,可以是1到3位数字,另一个用于名称. RecID将写入联结表,该联结表控制用户可以访问的分发列表.名称仅显示在确认页面上.
I need to create two variables, one for the RECID which can be 1 to 3 digits long, and one for the name. The RecID gets written to a junction table that controls what distribution lists a user would have access to. The name is just displayed on the confirmation page.
我是否正在尝试,还是应该研究一种不同的方式来传递RecID和名称?
Is what I'm trying even possible, or should I look into a different way of passing the RecID and name?
<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)?