1

I am using ColdFusion 2016. I have a form with a multi-select drop down. The name attribute of the field is called jobRoleId. When I submit this form the field name is available in the form scope as jobRoleId[]. How do I get the value of this field? The name comes across like an array but I can't seem to just dump out the value due to the brackets.

I've tried dumping out the value, but I get an error. I feel like I have done this in the past and the form field name didn't contain the brackets [] after the field name when using a multi select menu:

<select id="jobRoleId" name="jobRoleId" multiple="multiple">...</select>

Is there a way to somehow have the form field name just come across as jobRoleId?

writedump(jobRoleId[]); 
abort;
1
  • 1
    To access fields with invalid characters, use structure notation: form["jobRoldId[]"]. When I submit this form the field name is ... "jobRoleId[]" I think something else is responsible for the name change, not CF. I just tested it with CF2018 and even when this.sameFormFieldsAsArray = true;, it still submitted the field name as "jobRoleId".
    – SOS
    Commented May 24, 2019 at 21:05

2 Answers 2

2

When I execute your code I get a comma separated list for the values of jobRoleId. Are you using any CF frameworks?

My output:

enter image description here

I also suggest looking at the client side JavaScript to confirm there's nothing changing the submitted name. You can use the Chrome/Firefox/IE debugger to watch your submissions and confirm what is being submitted

2
  • 1
    I also suggest looking at the client side JavaScript to confirm there's nothing changing the submitted name. You can use the Chrome/Firefox/IE debugger to watch your submissions and confirm what is being submitted. Commented May 24, 2019 at 21:45
  • I am using the Coldbox framework @JasonHolden. I also am using jquery's $.ajax method and form.serialize() to send the data in so maybe is causing the values to come through this way. Commented May 25, 2019 at 1:13
1

Multi select lists, in CF, should return a list of values, as far as I remember...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.