ページ form.html に次のフォームがあり、cfpage.cfm に送信されます。名、姓、住所、および年齢がすべて表示されますが、一貫した順序ではありません。姓、名、住所、年齢が表示される場合があります。別の例では、住所、名、年齢、姓の順に表示される場合があります。
ユーザーがテキストボックスに入力したテキストを使用して、フォームに表示されている順序で CFLoop 項目を表示するにはどうすればよいですか? 複数の汎用フォームがあるため、cfpage.cfm で汎用コードを少し使用して、フィード フォームが送信するものをキャプチャする必要があります。
<form id="theform" name="theform" action="cfpage.cfm" method="post">
First Name
<input type="text" name="first name">
Last Name
<input type="text" name="last name">
Address
<input type="text" name="address">
Age
<input type="text" name="age">
</form>
cfpage.cfm のコード
<cfloop collection="#form#" item="theField">
<cfif theField is not "fieldNames">
#theField# = #form[theField]#<br>
</cfif>
</cfloop>