Recently on CF Talk Bobby Hartsfield presented an interesting problem. A vendor required a submission of data as an XML packet. Since the data all came from a form post Bobby wanted to simply loop through the form fields to build his XML file. Each of the form field names would become a node in his XML doc. Sounds simple right?
Actually there is a problem with this approach. XML is typically case sensitive. If the vendor uses all upper or all lower case that's not a problem because you could simply UCASE() or LCASE() the field names. But what if the XML node names need to be mixed-case? For example, what if a node name was AdminUserName? You could add a form element to the form called AdminUserName, but when it is posted Coldfusion turns it into all upper case - as in ADMINUSERNAME. It's too bad there is no way to access the original case of the form elements before ColdFusion intervened. As it turns out (and thanks to some nifty code from both Bobby and the very bright Barney Boisvert) there is a way....
It's easy to forget, but you have access to other ways of accessing the values posted to the page. You have access to the underlying context of the post with the little used "getPageContext( )" function. nested down the object tree is a method called getParameterNames() that will give you access to the case-insensitive field names before Coldfusion took charge. To help you out a bit further, here is a function that will return a structure of objects with case insensitive keys from the form.
To use this function there needs to be form variables in scope. Here's a test script: