[英]My radio button does not get the value from the foreach loop and form validation returns 'field required' even if its checked?
[英]get form field value from collection loop
我正在遍歷一個集合(表單),並測試表單字段名稱中的“ attachedFile”。 成功后,我想將表單字段值添加到數組。 目前,我只獲得表單字段名稱,而不是值。
<cfloop collection="#FORM#" item="field">
<cfif FindNoCase('attachedFile',field) IS 1>
<cfset fileNamesArray[fileNamesIndex] = field>
<cfset fileNamesIndex = fileNamesIndex + 1>
</cfif>
</cfloop>
我嘗試將索引[whatever]處的數組設置為#form.field#,但這會導致錯誤(未定義)。 任何想法如何在這個循環中獲得我的價值? 謝謝。
<cfloop collection="#Form#" item="field">
<cfset currentFieldName = field>
<cfset currentFieldValue = Form[field]>
</cfloop>
http://help.adobe.com/zh_CN/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172172e0811cbec22c24-7fe2.html
或者,如果您更喜歡腳本樣式,並且使用的是CF9,請使用for-in循環
<cfscript>
for (field in Form)
{
currentFieldName = field;
currentFieldValue = Form[field];
}
</cfscript>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.