Form controller - drop-down list support

142 views
Skip to first unread message

Shane Ebert

unread,
Jul 3, 2013, 7:41:25 PM7/3/13
to ibexexp...@googlegroups.com
Hi Alex.  I was wondering if it would be possible to support drop-down lists (<select>) with the Form controller? I guess I could use a text area and put the options afterwards, but it wouldn't be as clean.

Thank you so much,
Shane...

Corey Cusimano

unread,
Aug 26, 2013, 11:55:56 AM8/26/13
to ibexexp...@googlegroups.com
Shane, 

I added this to the Form controller:

                var drops = $(dom).find("select");
                for (var i = 0; i < drops.length; ++i) {
                    var drop = $(drops[i]);

                    rlines.push([["Field name", drop.attr('name')],
                                 ["Field value", drop.attr('value')]]);
                }

which allowed me to save the selection people made. Let me know if it works for you!

Shane Ebert

unread,
Aug 28, 2013, 8:38:54 PM8/28/13
to ibexexp...@googlegroups.com
Yes, that did it.  Thanks!  I ended up adding the ability to generate a warning if the participant doesn't pick an option.  This assumes that all menu's start with a blank item so that participants have to pick something, and this item has the value "BLANK".

First, you have to put this code somewhere above the code you provided, probably with the other similar declarations near the top of the controller script:

        this.obligatoryMenuErrorGenerator =
            dget(this.options, "obligatoryMenuErrorGenerator",
                 function (field) { return "Please pick an option for the menu \u2018" + field + "\u2019."; });

And then in side your code, you can add:

  if (select.attr('value') == "BLANK") {
              alertOrAddError(select.attr('name'), t.obligatoryMenuErrorGenerator(select.attr('name')));
        return;
  }

It worked for me, so hopefully it will work for other people.

Alex Drummond

unread,
Aug 28, 2013, 8:51:59 PM8/28/13
to ibexexp...@googlegroups.com
Thanks guys, I will add this code to the next version.
Alex 
--
You received this message because you are subscribed to the Google Groups "ibexexperiments" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibexexperimen...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Diogo Almeida

unread,
Apr 6, 2019, 3:59:01 PM4/6/19
to ibexexperiments
I am having the same problem with dropdown lists not showing up on the results file, and I found this thread. Unfortunately, it does not seem that this solution has been incorporated in the current version of Ibex (as of April 2019). Should I open an issue on Github?

Best,
Diogo

To unsubscribe from this group and stop receiving emails from it, send an email to ibexexperiments+unsubscribe@googlegroups.com.

giuliano bocci

unread,
Aug 12, 2021, 2:27:11 PM8/12/21
to ibexexperiments
Hi Alex, hi everyone, 
I know it's old post, but I was wondering if you may have a quick fix.
I am trying to add a couple few drop-down menus to an experiment. I have updated the form controller as proposed by Shane and it works like a charm in the old version of ibexfarm (https://spellout.net/ibexfarm/
However, by using the same controller (and the same html page) in the new version of ibexfarm (https://ibex.spellout.net/) the value selected from the drop-down list is not reported in the results. 
Am I missing something? Any piece of advice? 

Thanks in advance!
best 

Giuliano 

To unsubscribe from this group and stop receiving emails from it, send an email to ibexexperimen...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages