How To Access Badly Named Form Fields

Home » How To Access Badly Named Form Fields

A user just e-mailed me with a problem. He had to process the results of an existing form which was made up of fields named with invalid characters (one was “first name”). Trying to access the field as #FORM.first name# won’t work and will throw an error. So how to access these fields?
The answer is to remember that FORM is not just a prefix, it is also a structure. Structure members can be accessed as #structure.member# and as #structure[“member”]#. And that latter format will allow access to badly named form fields (as the name is enclosed in quotes). So, the solution is to use #FORM[“first name”]#.

2 responses to “How To Access Badly Named Form Fields”

  1. N Rohler Avatar
    N Rohler

    Just as a heads up– in my experience, some browsers post invalid form field names with spaces replaced with underscores.
    For example, ‘first name’ might come through as ‘first_name’.

  2. Barney Avatar

    This same technique is useful for poorly name query columns, or columns that are dynamic. #query["column name"][currentRow]#

Leave a Reply