0

I am getting different output when dumping results of a form submission with multiple fields with the same name. In CF8 I got only first html element value in output result but in CF11 I got value as a list. Is this specific to server running in CF8 & CF11. Below is the prototype of code I am using

<cfform method="post" action="">
    <select name="test">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
    </select>
    <input type="hidden" name="test" value="0">
    <input type="submit" name="btnsubmit" />
</cfform>


<cfif structKeyExists(form,"btnsubmit")>
    <cfdump var="#form#">
</cfif>

In CF8 I got results as '1' but in CF11 I got result as '1,0'.

Please let me know if this is specific to my server upgrade. I just want to know that in CF8 server multiple fields with same name returns value as list or only returns value of first element.

Jarede
  • 3,310
  • 4
  • 44
  • 68
Pradeep
  • 1
  • 1
  • Are you sure,that you have in CF8 file also. – krishna Ram Dec 10 '14 at 12:07
  • 2
    Um... standard HTML / HTTP protocol is that same-named form fields are *all* passed, and on the ColdFusion end of things this manifests as a comma delimited list of values. It's always been this way as far as I know (this stretches back to CF5). – Adam Cameron Dec 10 '14 at 13:00
  • Yes, is also in CF8 file also. One thing I got interesting during testing is that when I put before '' . That's make me totally confused. – Pradeep Dec 10 '14 at 13:24
  • That is as designed. I m not sure about the version but I think in version 10, same name html elements were started being treated as a list. Which was not the case with CF8. I believe there is Raymond Camden's blog too about it. – CFML_Developer Dec 10 '14 at 14:37
  • @cfml_developer, the new feature introduced in CF10 was putting values of multiple same-named form fields into arrays (with a setting in Application.cfc). Putting the values in lists has been around for a long time, as others have pointed out. – Carl Von Stetten Dec 10 '14 at 15:14
  • 1
    I agree with Adam, as far as I can remember, multiple fields with the same name built a list of values, just as the checkbox field always has. If you could 100% guarantee your fields were never blank and never contained a comma, you could name all rows of a multi-insert form the same names and loop that way (Really unwise to do that, but just an example). – Regular Jo Dec 10 '14 at 16:56
  • @Pradeep Try this code, just this `
    `. Try this on both CFs, you should get identical results.
    – Regular Jo Dec 10 '14 at 17:02

0 Answers0