Hi,
I am working with a dynamic form action page that creates an array of all formfield names and their corresponding values, then loops and outputs them into an email. The form is a basic HTML form, with hidden fields to define the TO, CC etc fields within CFMAIL.
The problem I have noticed, is that every email displays the field names and values in a different and totally random order. I would expect the output of field/values to be either in the order they appear in the HTML form, OR to at least list them alphabetically - but everytime the email is sent, the fields appear in a different order!!
The form action code:
<!--- Define Arrays to get the Field names and values --->
<cfset fieldArray = ArrayNew(1)>
<cfset valueArray = ArrayNew(1)>
<cfset testArray = ArrayNew(2)>
<!--- Open a loop to collect all the Form fields and Value --->
<cfloop collection="#form#" item="i">
<!--- Ignore Known field names and values --->
<cfif #i# is "EMAIL_TO" OR #i# is "SUBMIT" OR #i# is "FIELDNAMES" OR #i# is "RESET"
OR #i# is "CC_TO" OR #i# is "SUBJECT" OR #i# is "MYURL" or #i# is "ON_SUCCESS"
OR #i# is "ON_ERROR">
<cfset dummy="#i#">
<cfelse>
<!--- Add the E-mailable Field names and Values to respective Arrays --->
<cfset ArrayAppend(fieldArray,"#i#" >
<cfset ArrayAppend(valueArray,"#form#" >
</cfif>
</cfloop>
<!--- Generate the e-mail --->
<cfset to_element=#ArrayLen(fieldArray)#>
<cftry>
<cfmail to="#email_to#"
from="Xtranet@xtranet.com"
subject="#subject#"
cc="#cc_to#,#email_from#"
type="HTML">
This mail comes to you from the URL : #myurl#
<cfloop index="disList" from="1" to=#to_element# >
<p>#fieldArray["#dislist#"]# : <strong>#valueArray["#disList#"]#</strong></p>
</cfloop>
</cfmail>
<cflocation url = "#on_success#" >
<cfcatch type="Any">
<cflocation url = "#on_error#" >
</cfcatch>
</cftry>
Can anyone suggest a way in which we can set the order in which they are either entered into the array or outputted into the email that is consistent?
Thanks in advance
Eve
I am working with a dynamic form action page that creates an array of all formfield names and their corresponding values, then loops and outputs them into an email. The form is a basic HTML form, with hidden fields to define the TO, CC etc fields within CFMAIL.
The problem I have noticed, is that every email displays the field names and values in a different and totally random order. I would expect the output of field/values to be either in the order they appear in the HTML form, OR to at least list them alphabetically - but everytime the email is sent, the fields appear in a different order!!
The form action code:
<!--- Define Arrays to get the Field names and values --->
<cfset fieldArray = ArrayNew(1)>
<cfset valueArray = ArrayNew(1)>
<cfset testArray = ArrayNew(2)>
<!--- Open a loop to collect all the Form fields and Value --->
<cfloop collection="#form#" item="i">
<!--- Ignore Known field names and values --->
<cfif #i# is "EMAIL_TO" OR #i# is "SUBMIT" OR #i# is "FIELDNAMES" OR #i# is "RESET"
OR #i# is "CC_TO" OR #i# is "SUBJECT" OR #i# is "MYURL" or #i# is "ON_SUCCESS"
OR #i# is "ON_ERROR">
<cfset dummy="#i#">
<cfelse>
<!--- Add the E-mailable Field names and Values to respective Arrays --->
<cfset ArrayAppend(fieldArray,"#i#" >
<cfset ArrayAppend(valueArray,"#form#" >
</cfif>
</cfloop>
<!--- Generate the e-mail --->
<cfset to_element=#ArrayLen(fieldArray)#>
<cftry>
<cfmail to="#email_to#"
from="Xtranet@xtranet.com"
subject="#subject#"
cc="#cc_to#,#email_from#"
type="HTML">
This mail comes to you from the URL : #myurl#
<cfloop index="disList" from="1" to=#to_element# >
<p>#fieldArray["#dislist#"]# : <strong>#valueArray["#disList#"]#</strong></p>
</cfloop>
</cfmail>
<cflocation url = "#on_success#" >
<cfcatch type="Any">
<cflocation url = "#on_error#" >
</cfcatch>
</cftry>
Can anyone suggest a way in which we can set the order in which they are either entered into the array or outputted into the email that is consistent?
Thanks in advance
Eve